I'm trying to make a localscript that moves a named model with a humanoid that walks to Vector3.new(0,0,9000) on a push of a button. Ex. "1000ZBoyer (Player2)"
The First part of the name will be the player's name. Ex. 1000ZBoyer
I need some help to make this work properly.
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.KeyDown:connect(function (key)
for i, v in pairs(game.Players:GetChildren()) do
if key == "w" then
local nam = script.Parent.Parent.Character.Name.." (Player2)"
game.Workspace.FindFirstChild(nam).Humanoid.WalkToPoint = Vector3.new(0,0,9000)
end
mouse.KeyUp:connect(function (key)
if key == "w" then
local nam = script.Parent.Parent.Character.Name.." (Player2)"
game.Workspace.nam.Humanoid.WalkToPoint = game.Workspace.nam.Torso.Position
end
end)
end
end)
|