Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I make the LocalPlayer go to an Part when stepping on other???

Asked by 7 years ago

Posted this yesterday, I guess I had to be way specific. Im trying to make the Player, Move to an Specified Part, then after 5 seconds Move to other.

when Stepping on a part - Go to other - After 5 seconds - Go back!


local Member = game.Players.LocalPlayer
local Target = game.Workspace.Here
local Out = game.Workspace.out

function onTouch(hit)
    workspace.Member.Humanoid:MoveTo(Target.Position, Target)
    wait(5)
    workspace.Member.Humanoid:MoveTo(Out.Position, Out)
end

script.Parent.Touched:connect(onTouch)

**And yes. The Script is in a LocalPlayer ** The thing is that when the part it's touched. Nothing happengs.

2 answers

Log in to vote
-1
Answered by 7 years ago

You are welcome.

repeat wait() until game.Players.LocalPlayer.Character
local Member = game.Players.LocalPlayer
local Target = game.Workspace.Here
local Out = game.Workspace.out

game.Workspace.TouchPart.Touched:connect(function(hit)
   Member.Character.Humanoid:MoveTo(Target.Position)
wait(5)
    Member.Character.Humanoid:MoveTo(Out.Position)
end)

0
Thanks you SO much! PalomonCP 15 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You will not be able to move the player by their humanoid so instead you must use their torso because it is the root of the player's body which means it will transfer everything it holds. I also made some other changes because you had many other mistakes in your script that I can't really explain (I'm terrible at explaining so pardon my dust).

local Member = game.Players.LocalPlayer
local Target = game.Workspace.Here
local Out = game.Workspace.out

function onTouch()
    Member.Character.Torso.CFrame = CFrame.new(Target.Position)
    wait(5)
    Member.Character.Torso.CFrame = CFrame.new(Out.Position)
end

game.Workspace.TouchPart.Touched:connect(onTouch)

This is a LocalScript in StarterGui.

0
It works. But I don't want to teleport the player, I want to move him. PalomonCP 15 — 7y

Answer this question