Hey! I already made a post on this but I am remaking it because there were some things I left out that I shouldn’t have. I don’t know if this is allowed on the DevFourm so please tell me!
Anyway, I have a script that makes the Dummy walk around and talk. But, I am getting an error that I don’t know how to fix.
Here is the script:
function getRandomPhrase()
local playerName = script.Parent.Target.Value.Parent.Name
local phrases = {
playerName:upper() .. " IS IN THIS SERVER!!1",
"I MET " .. playerName:upper(),
"give " .. playerName:lower() .. " some space!",
"how did you get famous?",
"omg " .. playerName .. " plz don8",
"OMG LEAVE " .. playerName:upper() .. "ALONE",
playerName:upper() .. "!!1",
playerName .. " is just a normal person guys",
"will u don8",
"i am your biggest fan",
"how much robux u got?",
"plz join my group",
"HOLY TELAMON ITS " .. playerName:upper(),
"my brother loves ur game",
"im putting this in my blurb",
"second famous person i met 2day",
"GIVE " .. playerName:upper() .. " SPACE!!",
playerName:upper(),
playerName:lower(),
"no wonder famous people never talk",
"do you talk?",
"will you donate 100k R$ to me?",
"come to my place i need to show u a glitch",
"how much will u donate?",
"i can't believe it's " .. playerName,
"can u make me famous?",
"are you afk?",
"why wont you talk to me?",
"famous ppl never donate",
"famous people are greedy",
playerName .. " do you donate?",
"whats it like being a famous person?",
"how much tix u got man?",
"make me famous and ill give u 23 tix",
"can i copy ur game?",
"there are hackers at your game, plz ban them",
"buy gear from my place",
"can i take a screenshot?",
"i am recording this lol"
}
return phrases[math.random(#phrases)]
end
local function plusOrMinus(number)
return math.random(number - 4, number + 4)
end
local function randomize(v)
return Vector3.new(plusOrMinus(v.X), plusOrMinus(v.Y), plusOrMinus(v.Z))
end
wait(math.random())
local walkspeed = script.Parent.Humanoid.WalkSpeed
local hum = script.Parent.Humanoid
local head = script.Parent.Head
local torso = script.Parent.Torso
local target = script.Parent.Target.Value
while true do
if (torso.Position - target.Position).magnitude < 2 then
hum.WalkSpeed = 0
else
hum.WalkSpeed = walkspeed
hum:MoveTo(randomize(target.Position), target)
end
game:GetService("Chat"):Chat(head, getRandomPhrase())
wait(1)
end
The line it is failing on is:
if (torso.Position - target.Position).magnitude < 2 then
And here is the error:
Workspace.erik.cassel.WalkAndTalk:62: attempt to index nil with 'Position'
Help would be appreciated, thanks!