I see you don't understant client and server.
You don't have to tell the client who to teleport because each player has the same script and MouseButton1Down would run if that player clicks it.
Still don't understand?
You can get the local player by doing this local player = game.Players.LocalPlayer this doesn't work for a serverscript as there is only one server, there are multiple players.
To teleport that player just set his HRP Cframe (HRP = HumanoidRootPart)
You also didn't tell the script what 'Nyes' is so you'll either need script.Parent or tell it in a variable
Like this
local player = game.Players.LocalPlayer
local button = script.Parent
button.MouseButton1Down:Connect(function()
local char = player.Character
if char then
local HRP = char:WaitForChild('HumanoidRootPart')
end
end)
Then you'll have to set the CFrame, you have 2 options
Have a part already so you can teleport it to that part
Have the Coordinates so you can set it in the script
I'll use the first option
local player = game.Players.LocalPlayer
local button = script.Parent
local partTT = workspace:WaitForChild('TeleportPart')
button.MouseButton1Down:Connect(function()
local char = player.Character
if char then
local HRP = char:WaitForChild('HumanoidRootPart')
HRP.CFrame = partTT.CFrame
end
end)
If you want to know the other way...
local player = game.Players.LocalPlayer
local button = script.Parent
local pos = CFrame.new(Vector3.new(0,0,0))
button.MouseButton1Down:Connect(function()
local char = player.Character
if char then
local HRP = char:WaitForChild('HumanoidRootPart')
HRP.CFrame = pos
end
end)
If you have any more questions, just ask, please set this as best answer :)
1 comment
.