#Teleport using the Proximity Prompt

12 messages · Page 1 of 1 (latest)

acoustic sand
#

So i made door that can make you teleport to the target location using Proximity Prompt and script like this
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local RootPlayer = Character:WaitForChild("HumanoidRootPart")
local Button = script.Parent
local TargetLocation = game.Workspace:WaitForChild("ProTeleportC")
Button.Triggered:Connect(function()
RootPlayer.Position = TargetLocation.Position
end)

is everyone know what is wrong?. oh yah, in the terminal say Script 'Workspace.ProTeleportB.ProximityPrompt.Script', Line 2 - Studio - Script:2

pallid veldt
#

Is it a local script?

acoustic sand
#

nope

pallid veldt
#

You can't acces game.Players.LocalPlayer through a server script. Try this.

local ProximityPrompt = script.Parent
local TargetLocation = game.Workspace:WaitForChild("ProTeleportC")

ProximityPrompt.Triggered:Connect(function(player)
    local root = player.Character:FindFirstChild("HumanoidRootPart")
    root.CFrame = TargetLocation.CFrame
end)
sand furnaceBOT
#

studio** You are now Level 3! **studio

pallid veldt
acoustic sand
pallid veldt
# acoustic sand i mean, what is different my script with your script?

In the first line you're trying to access the player through game.Players.LocalPlayer you can't do that unless it's a local script. That's probably the only reason your script didn't work. I accessed the player through function in (player) and found the humanoidrootpart through player.Character:FindFirstChild("HumanoidRootPart")

acoustic sand
#

owh, i get it

sand furnaceBOT
#

studio** You are now Level 1! **studio

acoustic sand
#

thx