I'm creating a script which summons a snake. The snake however is NOT allowed to follow the owner, but it will follow anyone within a 40 stud radius. The script runs perfectly fine.
However, I want the snake to move just a little bit faster than the player so the snake touches the player and damages them. (Damage is done in a separate script). Any ideas how I would come about making the snake faster?
valuee = script.Parent.PlayersName.Value
repeat wait() until game.Players.ChildAdded
wait()
while true do wait()
for _, v in pairs(game.Players:GetChildren()) do
local plr = v.Character
if plr.Humanoid.Health > 0 and plr.Name ~= script.Parent.PlayersName.Value and plr.Name ~= "Snake" then
local head = plr.Head
if math.abs((head.Position-script.Parent.Head.Position).Magnitude) <= 40 then
script.Parent.Head.BodyPosition.Position = head.Position
elseif plr.Humanoid.Health > 0 and plr.Name == script.Parent.PlayersName.Value or plr.Name == "Snake" then
wait(0.1)
end
end
end
end
Thank you.

1 comment
Thank you for explaining the different components and thanks for answering!