Hello i don’t know how to script and i was wondering how i could make a spawn that you spawn in if you are on the list? like you were “Very Helpful” and the creator or mods want to put you in a better spawn i would like to spawn on the Admin room in my game. Please help
You can use a PlayerAdded event, then check if the player that entered is an admin, then teleport them to the admin room.
game.Players.PlayerAdded:Connect(function(player)
if player.UserId == (ADMINUSERID) then
player.Character.HumanoidRootPart.Position = (WHEREYOUWANTITTOTELEPORT)
else
return
end
If the code dosen’t work, don’t hesitate to reply to me.
Yeah it does not work
i also tried changing it’s location and type
What script is it in? The script is supposed to be a server script
i don’t know where to put it in
It’s supposed to be put in a regular script, and put the regular script in ServerScriptService.
I puted it in and it still does not work
So where the “ADMINUSERID” is, you’re supposed to change it to the UserId of the player you want access to, then put the “WHEREYOUWANTITTOTELEPORT” to where you want the player to teleport to.
The code is supposed to be in a regular script, not a local script, and put the regular script with the code into ServerScriptService.
Is this right?
game.Players.PlayerAdded:Connect(function(player)
if player.UserId == (11558680) then
player.Character.HumanoidRootPart.Position = (AdminSpawn)
else
return
end
You don’t have to put parentheses, and the spawn position has to be a Vector3 or a Part Position.
This is how I’d do it:
if player.UserId == 11558680 then
player.Character.HumanoidRootPart.Position = AdminSpawn.Position
else
return
end
You can rename the “AdminSpawn” to any spawn you want the player to teleport to when they join.
It still does not work ‘’‘’‘’’
Is there any errors? What’s the code?
it should be
if player.UserId == 11558680 then
player.Character.HumanoidRootPart.Position = workspace.AdminSpawn.Position
else
return
end
assuming the spawnlocation is located in workspace, however if you want a variety of people to spawn there something such as this
local admins = {
["15072007"],["friend"],["another friend"]
}
game.Players.PlayerAdded:Connect(function(plr)
if table.find(plr.Name,admins) then
plr.Character.HumanoidRootPart.Position = workspace.AdminSpawn.Position
end
end)
if player.UserId == 115586801 then
player.Character.HumanoidRootPart.Position = AdminSpawn.Position
else
return
end
Yeah that works too, you can just mark any of us as solutions.
Yeah, you have to put in workspace before the AdminSpawn if that’s where the admin spawn is, credits to @ekuz0diaa for calling it out.
game.Players.PlayerAdded:Connect(function(player)
if player.UserId == 115586801 then
player.Character.HumanoidRootPart.Position = workspace.AdminSpawn.Position
else
return
end
it still does not work ‘’‘’‘’’
editted my reply with a better example for this situation.
Should i overwrite the old part or it should stay?
overwrite the old part, as it may error out,