local t = script.Parent.Trainer.Value local g = Instance.new("BodyGyro",script.Parent) while wait() do local list = game.Workspace:GetChildren() for i = 1, #list do local n = list[i] if n.Name == t then local torso = n:FindFirstChild("Torso") script.Parent:WaitForChild("Pokemon"):MoveTo(torso.Position - (torso.CFrame.lookVector * 3),torso) g.cframe = CFrame.new(script.Parent.Torso.Position,torso.Position) end end end
This script causes my Pokemon to walk to the trainer that owns it. But for some reason, it doesn't work anymore. I found this out shortly after a roblox update and I want to fix it. Now when it runs, it seems to only move to it's set position once, and then it stops following completely.
NOTE: No errors have occurred.
Revised code:
local t = script.Parent.Trainer.Value local g = Instance.new("BodyGyro", script.Parent) while wait() do local list = game.Workspace:GetChildren() for i = 1, #list do local n = list[i] if n.Name == t then local torso = n:FindFirstChild("Torso") script.Parent:WaitForChild("Pokemon"):MoveTo(torso.Position - (torso.CFrame.lookVector * 3),torso) g.CFrame = CFrame.new(script.Parent.Torso.Position, torso.Position) end end end
I think the main problem is here (line 10): g.cframe = CFrame.new(script.Parent.Torso.Position,torso.Position)
.
Case-sensitivity is very important in Lua. I changed that to: g.CFrame = CFrame.new(script.Parent.Torso.Position, torso.Position)
. I also added spaces between the commas. This isn't required, but it helps me.
Replace your code with the code I provided above, and see if it works.
Hope this helped!