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

My teleport won't work when I publish my game but it works when I test it in studio? (Please Help)

Asked by
ZeeBaine -15
4 years ago

Hello, I need help with my teleport script. The teleport script teleport you to a position.

script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then hit.Parent.Head.CFrame = CFrame.new(--MY POSITION WANT TELLEPORTED--) end end)

It does work in all, but when I publish the game it wont teleport me. Please help!

If you can help please send me the script or send me the instructions

to how to fix it. Thanks

0
I would suggest changing the CFrame of the HumanoidRootPart to teleport. EmK530 143 — 4y

2 answers

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
script.Parent.Touched:Connect(function(hit)
 if hit.Parent:FindFirstChild('Humanoid') then 
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local placeId = 0 -- replace here
local userId = 1 -- replace with player's userId
-- find the player
local player = Players:GetPlayerByUserId(userId)
-- teleport the player
TeleportService:Teleport(placeId, player)


end 


end)

0
He didn't mean an actual teleport, I think he meant to position the character. Infocus 144 — 4y
Ad
Log in to vote
0
Answered by
Infocus 144
4 years ago

--Put this inside a part

script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then hit.Parent:MoveTo(Vector3.new(0, 0, 0)) -- ADJUST HERE end end)

Answer this question