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

Can I fix my Click Teleport?

Asked by 7 years ago
Edited 7 years ago

I have a teleport thet when you click it, it should teleport you to a part. The teleporter works perfectly, the only problem is that instead of only teleporting yourself, it teleports everyone in game. Here is the script

function onClicked()

local c = game.Players:GetChildren() 
for i = 1, #c do 
c[i].Character.Torso.CFrame = CFrame.new(script.Parent.Parent.Click2.Position) 
end 

end 

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Thanks

2 answers

Log in to vote
0
Answered by 7 years ago
function onClicked(PlayerWhoClicked)
PlayerWhoClicked.Character:MoveTo(script.Parent.Parent.Click2.Position)

script.Parent.ClickDetector.MouseClick:connect(onClicked)

You had to say which player clicked the button, to do that; I used a function argument. You also used game.Players:GetChildren(), which would explain why it teleported everyone.

0
Thanks! maxbthecool3 6 — 5y
Ad
Log in to vote
0
Answered by
WindNT 16
7 years ago
Edited 7 years ago

Hi! This can be a very frustrating problem! Luckily it has a very simple solution!

I believe what you are trying to accomplish can be done with this code here:

--Need to change what part your player teleports to?
--Change the path to the part before the plus sign
--
--For Example: script.Parent.Parent.Click3

function onClicked(plr)
    plr.Character.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.Click2.Position + Vector3.new(0,4,0))
end
script.Parent.ClickDetector.mouseClick:connect(onClicked)

When a player clicks the part that this script is in, it will TP ONLY the player that clicked, to the part named "Click2". The reason I added:

+ Vector3.new(0,4,0)

is to prevent the player from getting jammed in to the part that they are teleporting to. It means move the player an additional 4 studs UP from the location it is teleporting to. There is also a great Roblox Wiki article that demonstrates this. I refer to it all the time!

http://wiki.roblox.com/index.php?title=Teleportation

Hope this Helps :D

Let me know if you have any more questions!

If this solves your problem, remember to accept this answer. It helps me out a bunch and so others can see the solution.

Cheers! WindNT

Answer this question