Hey, I want to make my code so it makes you respawn at a certain location(s) if you die in a certain region. I have tried numerous ways of getting help at this such as: Discord Servers, DevForum, Youtube, Toolbox. But none have really explained to me what I can do to 1) Achieve it or 2) Do it. Here is my code:
local places = game.Workspace.FFASpawns
local locations = {places.One,places.Two,places.Three,places.Four,places.Five,places.Six}
local somerandom = math.random(1,#locations)
local region = Region3.new(game.Workspace.ffaPart.Position-game.Workspace.ffaPart.Size/2,game.Workspace.ffaPart.Position+game.Workspace.ffaPart.Size/2)
local isapart = Instance.new("Part",workspace)
isapart.Size = region.Size
isapart.CFrame = region.CFrame
isapart.Transparency = 1
isapart.Anchored = true
isapart.CanCollide = false
while true do
wait()
local partsInRegion = workspace:FindPartsInRegion3(region,nil,40)
local playersFound = {}
for i, part in pairs(partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") then
char.Humanoid.Died:Connect(function()
local player =game.Players:GetPlayerFromCharacter(char)
player.CharacterAdded:Connect(function()
char.HumanoidRootPart.CFrame = somerandom.CFrame
end)
end)
end
end