msg
#1
I am pretty proud of this non-working script... At 3:21 in the morning, even when rushed, I did good.

The script is suppose to:
  • make a TextValue in Storage
  • make an NPC when someone says "clone;"
  • changes the NPC's name to a random number up to 10,000 (and not have that same number chosen again by any person in the game, not implemented)
  • change the NPC's regular body to the speaker's body
  • create a label saying the speaker's name, then "'s Clone"
  • copy the NPC into a TextValue in Storage
  • print "You have successfully created a clone."


[lua]t = create("TextValue")
n = create("NPC")
l = create("Label")

if msg == "clone;" then
n.Parent = game.Workspace
t.Parent = game.Storage
t.Name = speaker.Name
l.Parent = n
l.Text = speaker.Name .. "'s Clone"
n.Name = math.Random(1,10000) -- I don't know if this line is correct.
n.Body:remove()
speaker.Body:clone().Parent = n
n:clone().Parent = t
print("You have successfully cloned yourself.")
end[/lua]

Yes, I do know that this script could have been made easier, however, I chose not to show my newbie side in scripting.

EDIT: I retried the script; the TextValue ended up spawning, however, in the World. The script stopped after it was generated. It also ONLY generated the TextValue, even if the NPC was first.
All my mods are available here.
Reply
#2
Instead of

[lua]
n.Name = math.Random(1,10000)
n.Body:remove()
speaker.Body:clone().Parent = n
[/lua]

Try

[lua]
n.Name = tostring(math.random(1,10000))
n.Skin = speaker.Character.Skin
[/lua]

if speaker is a Player.
Reply
#3
(06-28-2011, 01:01 PM)Qwertygiy Wrote: Instead of

[lua]
n.Name = math.Random(1,10000)
n.Body:remove()
speaker.Body:clone().Parent = n
[/lua]

Try

[lua]
n.Name = tostring(math.random(1,10000))
n.Skin = speaker.Character.Skin
[/lua]
if speaker is a Player.

Thanks, but the sixth line in was incorrect. I put .Workspace, not .World. Big Grin Still fails to work, and I have done tweaks here and there:

[lua]t = create("TextValue")
n = create("NPC")
l = create("Label")

if msg == "clone;" then
n.Parent = game.World
t.Parent = game.Storage
t.Name = speaker.Name
l.Parent = n
l.Text = speaker.Name .. "'s Clone"
n.Name = tostring(math.random(1,10000))
n.Skin = speaker.Character.Skin
n:clone().Parent = t
print("You have successfully cloned yourself.")
end
[/lua]
All my mods are available here.
Reply
#4
lol I do that a lot also.

I'll use wait() instead of sleep()

Tongue
Reply
#5
I rewrote the script.

[lua]--[[
I have no idea this one script is causing me so much grief...
]]

if msg == "/clone" then
clone = create("NPC")
clone.Parent = game.World
clone.Skin = speaker.Character.Skin
clone.Name = tostring(math.random(1,10000))
label = create("Label")
label.Parent = clone
label.Text = speaker.Name
model = create("Model")
model2 = create("Model")
model.Parent = game.World
model2.Parent = game.Storage
model.Name = speaker.Name
model2.Name = speaker.Name
clone:clone().Parent = model2
print("You have created " .. clone.Name .. ", remember this name to restore and delete.")
end[/lua]

I am going to re-write it a third time to be even more advanced then this; e.g. someone can actually make their label name for the NPC, ect

I'll also add a "/follow" and "/stop" command after I implement the "/remove" commands.
All my mods are available here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)