Xoaxxe

Helping out I_Hashi

May 22nd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | None | 0 0
  1. game.Players.PlayerAdded:Connect(function(newPlayer)
  2.     if newPlayer:IsInGroup(7) then
  3.         game.Workspace.DefaultSpawn:Destroy()
  4.         local GroupSpawn = Instance.new("SpawnLocation", game.Workspace)
  5.         GroupSpawn.Name = "GroupSpawn"
  6.         GroupSpawn.Position = Vector3.new(0, 0, 0)
  7.     end
  8. end)
  9.  
  10. --The first thing you want to do is check if the player is in one of the groups, to do this you would do the following,
  11.  
  12. game.Players.PlayerAdded:Connect(function(newPlayer)             -- this calls the function whenever a new user joins the game, "newPlayer" could be called anything what matters is that with the PlayerAdded function this is always equal player name
  13.    if newPlayer:IsInGroup(7) then                                -- here you check if newPlayer is in a specific group, the id "7" would be your group id          
  14.       print("This user is in the group.")                        -- this is what happens if they are in the group    
  15.    end                                                           -- here they close the if statement
  16. end)                                                             -- here they close the function
  17.  
  18.                                                                  -- now that we have checked if they are in the group we need to decide what happens if they are in the group, I recommend you rename the spawnpoints to something relating to the group name, for example, if the group name is "Group name" then you should rename its spawnpoint to something like "GroupNameSpawn"
  19.  
  20. game.Workspace.DefaultSpawn:Destroy()                            -- the part "game.Workspace.DefaultSpawn" is just the location of the default spawn, ":Destroy()" deletes that part, but just remember to put this in a local script so that it doesn't destroy the spawn for everyone
  21. local GroupSpawn = Instance.new("SpawnLocation", game.Workspace) -- here we create a new spawn point and set its parent to the workspace, the reason we make it a variable is so that we can edit it more separately from this statement
  22. GroupSpawn.Name = "GroupSpawn"                                   -- here we change the name of the spawn itself, because before the name was just a variable, and not actually the name of the spawn
  23. GroupSpawn.Position = Vector3.new(0, 0, 0)                       -- replace the zero's with the position you want the spawn, if you dont know then place a part where you want it and copy its position and paste it into the (), make sure it is formatted the same as the zeros.
  24.  
  25.  
  26. -- the final result should look sommething like this:
  27. game.Players.PlayerAdded:Connect(function(newPlayer)
  28.     if newPlayer:IsInGroup(7) then
  29.         game.Workspace.DefaultSpawn:Destroy()
  30.         local GroupSpawn = Instance.new("SpawnLocation", game.Workspace)
  31.         GroupSpawn.Name = "GroupSpawn"
  32.         GroupSpawn.Position = Vector3.new(0, 0, 0)
  33.     end
  34. end)
  35.  
  36. -- make sure that you replace the group id with the group you want it to check for and the vector3 position with the position on the spawn
  37. -- you also need to do this for each group id
Add Comment
Please, Sign In to add comment