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

How do I create a spawn for a certain area but when you leave it resets back to the main spawn?

Asked by 3 years ago

I'm trying to create a small sword fighting area in my game, and I want it to be when you enter the area, it sets a new spawning location so when you die, it spawns you back at a certain location in the area but then when you leave the area, it sets your spawn location back to the main map which will be quite far away.

How am I able to do this?

0
Region3 and the Player.Respawn property can achieve this. Region3: https://developer.roblox.com/en-us/api-reference/datatype/Region3 . Player.RespawnLocation: https://developer.roblox.com/en-us/api-reference/property/Player/RespawnLocation MarkedTomato 810 — 3y
0
I usually use CFrames for teleportation IshmaelKGaano 6 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I usually use CFrames for teleportations

Heres an Example

local plr = game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
local Teleport1 = workspace.Part1
local Teleport2 = workspace.Part2
local debounce = false


Teleport1.Touched:Connect(function()
    if debounce == false then
        debounce = true
        HumanoidRootPart.CFrame = Teleport2.CFrame
        wait(4)
        debounce = false
    end
end)

0
Where would I insert the script into? ezyriiaa 0 — 3y
Ad

Answer this question