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

How can i change the respawn location?

Asked by 5 years ago

the script is a local script inside the gui

local player = game:GetService("Players").LocalPlayer

game.Workspace.teleport.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid") then

player.RespawnLocation = Vector3.new(game.Workspace.teleport.Position)

end

end)

but im only getting the error "Players.Gameplayer365247v2.PlayerGui.ScreenGui.speed.LocalScript:4: bad argument #3 to 'RespawnLocation' (Object expected, got Vector3)" idk what that means

0
that is the same thing as i did just with longer text so it wont work, because the position holds those 3 positions Gameplayer365247v2 1055 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Firstly, the Property RespawnLocation is suppose to be a SpawnLocation part(not a regular part), not a Position. Second, if you have workspace.FilteringEnabled on, then this script should not be in the client side.

Make a new regular script in workspace which would have this code in it:

local Players = game:GetService("Players")

workspace.teleport.Touched:connect(function(Part)

local Player = Players:GetPlayerFromCharacter(Part.Parent) --if a part of your player touches it, then Part.Parent would be the character model that part is in, and :GetPlayerFromCharacter gets the player in Players from that character model

if Player then

Player.RespawnLocation = workspace.teleport

end

end)
0
i dont have filtering enabled and i dont want it on Gameplayer365247v2 1055 — 5y
0
this will work whether or not FilteringEnabled is on. Your original script won't. alex_ander 163 — 5y
0
well i tested the script both exacly as u did it and with workspace.teleport.Position and neither worked, with ur script there was an error processing data and with mine there was some vector3 problem Gameplayer365247v2 1055 — 5y
0
Is the teleport part a SpawnLocation or a regular Part? alex_ander 163 — 5y
Ad

Answer this question