i want to character follow the player that was set in object value but when im writing local with object value it just says "attempt to index nil with FindFirstChild "
local NPC = script.Parent
while true do
local player = script.Parent.Parent.Creator.Value
NPC.Humanoid:MoveTo(player:FindFirstChild("HumanoidRootPart").Position)
local stopped
NPC.Humanoid.MoveToFinished:Connect(function()
stopped = true
end)
repeat
local distance = (NPC:WaitForChild("HumanoidRootPart").Position-player:FindFirstChild("HumanoidRootPart").Position).Magnitude
if distance < 10 then
NPC.Humanoid:MoveTo((NPC.HumanoidRootPart.CFrame*CFrame.new(5,0,0)).p)
break
end
wait()
until stopped == true
wait(0.5)
end
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild ("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if db == true then
db = false
local BTTCharacters = game:GetService("ReplicatedStorage").BTTCharacters:Clone()
BTTCharacters.Parent = player.Character
BTTCharacters.Creator.Value = player.Character
task.wait(0.5)
BTTCharacters:PivotTo(player.Character:WaitForChild("HumanoidRootPart").CFrame)
wait(1)
db = true
end
end
end)
I gave you a possible answer approximately 202,980 seconds ago. Also don’t even bother trying to press out an answer with that cheesy ahh sentence, it’s just pathetic.