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

How Can I Set A Main SpawnLocation If I Have More Than One SpawnLocation Part ?

Asked by
Split_s 21
3 years ago

So , I Have 3 SpawnLocations Inside My Game , The First One I Want To Be The Main One Where Everyone Spawns , The Other 2 SpawnLocations That Are Used For Something Else And I Cant Disable Them Since It Will Break The Scripts That Is Inside Them (The 2 SpawnLocations Are Used For A Checkpoint-Like System) , When I Enter The Game It Randomly Selects One Of The 3 SpawnLocations To Spawn Me At And I Don't What That , Does Someone Have Any Solution For This ? I Literally Cannot Find Anything To Fix My Problem

For An Idea , This Is The Script Inside The "Checkpoints"

local sound = script.Parent.Parent.Parent.Sound

script.Parent.Triggered:Connect(function(plr)

    sound:Play()
    plr.RespawnLocation = script.Parent.Parent.Parent.Respawn

end)

Layout

Click Me (ImgBB)

2 answers

Log in to vote
0
Answered by 3 years ago

ServerScript:

game.Players.PlayerAdded:Connect(function(playerThatJoined)
   playerThatJoined.RespawnLocation = script.Parent.Parent.Parent.Respawn

end)

Explanation

This code will run as soon as the player joins using the PlayerAdded event with the parameter "playerThatJoined" you can name the parameter, "player" but for now, I'm just trying to make it as clear as possible. After that, it sets the RespawnLocation of the player that joined to a specific SpawnLocation

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Instead of using spawn parts, you can just use regular parts and rename them.

Then you can just do

local fakeCheckpointA = path
local fakeCheckpointB = path
local fakeCheckpointC = path

--set the players primary part cframe 3 studs above your fake checkpoint
plr:SetPrimaryPartCFrame(fakeCheckpointA.CFrame + Vector3.new(0, 3, 0))

Answer this question