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

Howdy, I need help with the spawns in my game?

Asked by 6 years ago

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?

0
I had this issue. in the end what I did was, just has one spawn where all the players spawn at the start of the game, and when the player presses a button when they want to join a team, I would set their team to that, and then move their HumanoidRootPart.CFrame one of the parts called Spawn. If you would like a script, please tell me tonyv537 95 — 6y
0
My script is when you press a button (a deploy button) and they teleport to one of the parts I called (spawn part) and they teleport to a random one tonyv537 95 — 6y
0
Oh, that would be awesome! I would love that script, thank you. llMasonIl 12 — 6y

1 answer

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

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.

Ad

Answer this question