could you try printing out player?
script.Parent.MouseButton1Down:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.Position = workspace.Spawntp.Position
end
Simple, you’re trying to get the player from an event that can’t get the player. Instead, we can just use game.Players.LocalPlayer, because this is a LocalScript!
You could try adding a WaitForChild() when looking for the “Spawntp” or at the very beginning, if your script is a Local Script, add this line that will yield the script until it finds the player’s Character, preventing any errors when looking for the player.
if not game.Players.LocalPlayer.Character then game.Players.CharacterAdded:Wait() end
if i do this the camera of the player goes to a weird position, what i think is that the camera stays on position and the player teleports
Use this script for teleportation
local Player = game.Players.LocalPlayer
local char = Player.char
script.Parent.MouseButton1Click:Connect(function()
char:SetPrimaryPartCFrame(Spawntp.CFrame)
end)
I did not get what you meant by the camera being in a weird position, though
i get a error by the word Spawntp
i think if i tp the player teleports and the camera not
(in a local script)
local plr = game.Players.LocalPlayer
local char = plr:WaitForChild("Character")
local SpTp = workspace:WaitForChild("Spawntp")
script.Parent.MouseButton1Click:Connect()
char.HumanoidRootPart.CFrame = SpTp.CFrame
end
if this doesnt work try changing CFrame to Position
Use GetPivot() and PivotTo() to move the character, and face your SpawnTp part in the direction you wish the player to face after teleport.
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait();
local spawn_position = game.Workspace:WaitForChild("SpawnTp",3);
if spawn_position and spawn_position:IsA("BasePart") then
character:PivotTo(spawn_position:GetPivot());
end
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
player.CharacterAdded:Wait()
local xD = Mouse.Button1Up:Connect(function()
player.Character.HumanoidRootPart.CFrame = workspace.Spawntp.CFrame
end)
xD:Dissconnect()
Your error:
You need to get UIS or Mouse First Idiot
It should be workspace.Spawntp.CFrame
instead.
You haven’t stored Spawntp as a varible. Yes the girl above me corected it. Mark my answer as the solution when it works
I’m pretty sure he’s using a UI
Try WaitForChild for the character and spawn tp
and also i think ur trying to teleport a player using client scripts
Yep, I think he’s using a GUI to tp players
you guys introduced him to remotes yet?
Nope…but. I probably should’ve