Hello my fellow friends, So I made a lobby where people start in before an intermission. So I have a part that moves and kill player but the part is in a game not in the lobby. I want the part to stay in place until the intermission count down is over then when a player enters the game after the intermission the part will start moving
What is the issue? The part moves before the intermission is over and when the players spawn in the game the part is already gone out of the map.
What solutions have you tried so far? I have tried to make the part go slower so that when the player spawns the part would have the chance to kill players but making the part slow didn’t help because the player would have more time to do the task.
Also I tried to makeup this code but it didn’t work
while true do wait for player spawn() -- In the brackets I add the spawn location "GameSpawn" which didn't work
then
script.Parent.Size = script.Parent.Size - Vector3.new (20, 0, 20)
end```
spawn is used for threading code, unless you created a custom function for it and wait is a global function.
You can use bindable events for this instead of loops
example:
local event = Instance.new("BindableEvent")
event.Event:Connect(function()
-- round code here
end)
To start, what’s the code that you use for intermissions?
Once the intermission is over, you can fire an event:
event:Fire(...) -- "..." would be for the arguments you want to send (if any)
-- but for this example, i'll send "true"
event:Fire(true)
and have the game detect that event and wait for the player to spawn
event.Event:Connect(function(arg)
-- code to teleport the players to the map (unless you have that in a different script)
if arg then -- if "arg" is not "nil" or "false"
-- script that makes the brick spin here
end
end)
However, the code only works from server script to server script, if you want the client to send requests to the server, you would use RemoteEvents
So, in this instance, we would need to use RemoteEvents
local Timer = script.Parent.Timer
local Event = -- path to remote event
local TargetValue = -- the value that the status needs to be to let the game start
script.Parent.Text = Status.Value
Status.Changed:Connect(function()
script.Parent.Text = Status.Value
if Status.Value == TargetValue then -- the status is equivalent to the status needed to start the game
Event:FireServer() -- send a request to the server
end
end)
-- server script
local event = -- path to remote event
event.OnServerEvent:Connect(function(player) -- the player who fired the remote is automatically passed
-- code here
end)
So do I make the remote event in replicated storage? and add the script in server script service? and this is the finished script for the intermission i was watching The Dev king but the script didn’t work
local intermissionLength = 10
local Inround = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local LobbySpawn = game.Workspace.lobbyspawn
local GameAreaSpawn = game.Workspace.gamespawn
local function Roundtimer()
while wait() do
for i = intermissionLength, 1, -1 do
Inround.Value = false
wait(1)
Status.Value = "Intermission: ".. i .." seconds left!"
end
for i = roundLength,1, -1 do
Inround.value = false
wait(1)
Status.value = "Game "..i.."seconds left"
end
end
end
spawn(roundLength)
)```
Sorry, I can’t go into studio right now, do you update the text at the end of each for loop
example:
for i = intermissionLength, 1, -1 do
Inround.Value = false
wait(1)
Status.Value = "Intermission: ".. i .." seconds left!"
script.Parent.Text = Status.Value -- placeholder text updater, it might be different in-studio
end