Hi devs, i really need your help . Actually i have made a script where somes event are happening every X time, but i have a problem. I want to make a system that :
First Situation
The event is launched.
the door open
No players are entered on it.
The event closes after 60 secondes
and another event is launched.
But i want this situation could be possible too :
The event is launched.
the door open
A player enter on the event.
no other event starts while one player is in the event.
A player exit the event
door close
and another event is launched.
But actually idk how to make that … Could someone can help me ? Here is my script for an event :
local EventNames = {"SousSol"}
SousSol = function()
print("SousSol")
local Door = game.Workspace.Evenements.SousSol
local frameOpen = Door:WaitForChild("DoorFrameOpen")
local frameClose = Door:WaitForChild("DoorFrameClose")
local frame = Door:WaitForChild("DoorFrame")
local tweenService = game:GetService("TweenService")
local OpenSound = frame.DoorOpen
local CloseSound = frame.DoorClose
local SousSolValue = game.ReplicatedStorage.ValuesEvents.SousSol
local EventCompleted = game.ReplicatedStorage.ValuesEvents.SousSolCOMPLETED
local StopSousSol = game.ReplicatedStorage.StopSousSol
if EventCompleted.Value == 1 then
StopSousSol:FireAllClients()
StopSousSol.OnServerEvent:Connect(function()
local dead = false
local thread = nil
thread = StopSousSol.OnServerEvent:Connect(function()
thread:Disconnect()
dead = true
end)
while dead == false do
-- Nothing here, just kill the event
end
end)
else
print("SousSol Start")
OpenSound:Play()
frame.CanCollide = false
Door.EventTitle.billboardGui.Enabled = true
Door.EventTitle.EventTitle.billboardGui.Enabled = true
frame.Knobs.Transparency = 1
frameClose.Knobs.Transparency = 1
frameOpen.Knobs.Transparency = 0
game.Workspace.AllTpParts.BasementTp.TeleportPart1.CanCollide = true
game.Workspace.AllTpParts.BasementTp.TeleportPart1.Transparency = 0
tweenService:Create(frame,TweenInfo.new(.35),{CFrame = frameOpen.CFrame}):Play()
-- Need help here , to check if player is on the event or nah and if he leaved the event too..
print("Event end sousol")
CloseSound:Play()
frame.CanCollide = true
frame.Knobs.Transparency = 0
frameClose.Knobs.Transparency = 0
frameOpen.Knobs.Transparency = 1
Door.EventTitle.billboardGui.Enabled = false
Door.EventTitle.EventTitle.billboardGui.Enabled = false
game.Workspace.AllTpParts.BasementTp.TeleportPart1.CanCollide = false
game.Workspace.AllTpParts.BasementTp.TeleportPart1.Transparency = 1
tweenService:Create(frame,TweenInfo.new(.35),{CFrame = frameClose.CFrame}):Play()
end
end,
}
while true do
local EventName = EventNames[RandomObject:NextInteger(1, #EventNames)]
Events[EventName]()
print("Event searching")
task.wait(5) --Wait 60 seconds between events when game will be published.
end