I created in a local script, which is designed to teleport the player to a given point:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.Character:Wait()
Character:MoveTo(game.Workspace.Shop.TeleportPart.Position)
Normally my script works fine, but it doesn’t work today.
I tried to teleport the player to the block’s position, but it didn’t work either.
No error is shown in output.
What should I do?
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Character:PivotTo(game.Workspace.Shop.TeleportPart.CFrame)
Few notes:
1.You forgot to put Added in the or Player. part.
2.Why not teleport the player from a server script?
3.I think it’s always better to use either PivotTo or SetPrimaryPartCFrame[deprecated, but still works].
@DeltOof12345@barfpillow99@DesertedVoltron@Paysallday44
I changed the local script to server script, but it doesn’t make much difference to me. I was already doing a local script in the GUI that teleported the player and everything worked fine.
Explorer SS
Now the message pops up in output:
11:27:24.264 Workspace.Room.Door.Union.Script:4: attempt to index nil with 'Character' - Server - Script:4
11:27:24.265 Stack Begin - Studio
11:27:24.265 Script 'Workspace.Room.Door.Union.Script', Line 4 - Studio - Script:4
11:27:24.265 Stack End - Studio
wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false
function teleport()
if not debounce then
debounce = true
LowerTorso = player.Character.LowerTorso
LowerTorso.CFrame = game.Workspace.Part.Place1.CFrame
end
end
button.MouseButton1Click:Connect(teleport)
while true do wait()
debounce = false
wait(1)
end
thats a weird way of doing debounces you should probably do
local player = game.Players.LocalPlayer
local button = script.Parent
local debounce = false
function teleport()
if not debounce then
debounce = true
local chr = player.Character or player.CharacterAdded:Wait()
local HRP= chr.HumanoidRootPart
HRP.CFrame = game.Workspace.Part.Place1.CFrame
task.delay(1, function() debounce = false end)
end
end
button.MouseButton1Click:Connect(teleport)
local open = script.Parent.MouseButton1Click:Connect(function()
script.Parent.Frame.Visible = true
script.Parent.Text = "Close"
end)
CloseFrame’s Text = X
CloseFrame’s script:
local close = script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Text = "Open"
end)
TextButton1’s Text: Place1
TextButton1’s script:
wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false
function teleport()
if not debounce then
debounce = true
LowerTorso = player.Character.LowerTorso
LowerTorso.CFrame = game.Workspace.Part.Place1.CFrame
end
end
button.MouseButton1Click:Connect(teleport)
while true do wait()
debounce = false
wait(1)
end
TextButton2’s Text: Place2
TextButton2’s script:
wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false
function teleport()
if not debounce then
debounce = true
LowerTorso = player.Character.LowerTorso
LowerTorso.CFrame = game.Workspace.Part.Place2.CFrame
end
end
button.MouseButton1Click:Connect(teleport)
while true do wait()
debounce = false
wait(1)
end
TextButton3’s Text: Place3
TextButton3’s script:
wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false
function teleport()
if not debounce then
debounce = true
LowerTorso = player.Character.LowerTorso
LowerTorso.CFrame = game.Workspace.Part.Place3.CFrame
end
end
button.MouseButton1Click:Connect(teleport)
while true do wait()
debounce = false
wait(1)
end
The TextLabel does not have any script because there’s no script BUT the Text is: Teleporter