So, I got 3 spawns setup. Raiders, Civilians, VFI. The teams and spawns match each other, but for some reason when I become VFI, I either spawn at the Raiders spawn, or the civilians one, AND only sometimes I spawn at the actual VFI spawn. Any tips, or a fix for my situation?
https://imgur.com/a/wUWU1LK <--- Some screenshot evidence that there correctly made
Is there a script or something, where if there on a certain team it will teleport them to the block of my choosing?
Hello, In response to your comment, here is a way in which you can teleport players to a brick of your choice.
So basically, in my game, I have it so there is only ONE spawn, where all the payers spawn at but the camera is fixed in another spot, and the fiddle with the GUIs until they come upon the "Deploy Button", which is when the camera is set back to normal and they teleport to one of the parts which I called "Spawn1", "Spawn2", etc until "Spawn8".
For the other team, I did the exact script but I made new spawns and changed their names to "BSpawn1" etc. And in the script I changed the variable to
~~~~~~~~~~~~~~~~~
local spawnpart = game.Workspace:FindFirstChild(BSpawn..math.Random(1,8))
Ignore the camera bit, because in my game I am working on, I have the camera fixed in place and when you press deploy, the camera goes back to normal.
I can explain it too.
So first I defined the variables. Keep the camera bit just to prevent any camera glitches when you teleport.
Then when you press the button, (define the all the spawns parts 1 - 8) If you want only one block then just do
~~~~~~~~~~~~~~~~~
local spawnpart = game.Workspace.Spawn1 -- Change the directory to where your part is. If you don't have the right place, the spawns won't be recognised and the script will break.
then you want to define the HumanoidRootPart. This is the main part of the humanoid and is needed to teleport players.
After defining it, you want to teleport it by setting it's CFrame to a CFrame.new(x,y,z). The XYZ positions you need are the ones from the part(s) you're gonna teleport the player to. But you want to add a few extra on the Y value, so they won't glitch into the ground or whatever.
so it would be :
humanoidRootPart.CFrame = CFrame.new(spawnpart.Position.X, spawnpart.Position.Y + 5, spawnpart.Position.Z)
As you can see, an extra 5 studs was added to help prevent my players from getting stuck into the ground.
This is the script I used. Please do change it to your needs. This occurs when I press a button, if you want it to occur another way, research it, A good place to look is the Wiki.
-- Variables local players = game:GetService("Players") local player = players.LocalPlayer local button = script.Parent local Camera = game.Workspace.CurrentCamera button.MouseButton1Click:Connect(function() local spawnpart = game.workspace:FindFirstChild("Spawn"..math.random(1,8)) -- the number of spawns you have. I have 8. My spawn parts are called "Spawn1" and "Spawn2" etc up to 8. So i define all the spawn parts using this. local humanoidRootPart = player.Character.HumanoidRootPart -- define the part of the body you're gonna teleport humanoidRootPart.CFrame = CFrame.new(spawnpart.Position.X, spawnpart.Position.Y + 5, spawnpart.Position.Z) -- The teleportation is here. You move the end) button.MouseButton1Click:Connect(function() Camera.CameraType = 'Custom' Camera.CameraSubject = player.Character end)
I hope this was useful, Thanks.
Tony
Please Accept this answer if it was good and useful for you.