Hello!
I have got a server script where it fires WaitLavaRem to all clients
WaitLavaRem:FireAllClients(LavaRise)
This is a round system and it fires once per round. The first two rounds work fine but on the third round it fires once and receives twice, the fourth round, fires once receives thrice. ETC
Server Script:
local timer = 20
AddRemoveTimeRem.OnServerEvent:Connect(function(player, Time, Action)
if Action == "Add" then
timer += Time
elseif Action == "Remove" then
timer -= Time
end
timer = math.max(timer, 0)
print(timer)
end)
local function PlayOneRound()
-- refill planes if needed
while true do
if not TotalPlanes or #TotalPlanes == 0 then
print("Refilling TotalPlanes")
TotalPlanes = table.clone(PlaneModule)
end
local RandomPlane = math.random(1, #TotalPlanes)
local SelectedPlane = TotalPlanes[RandomPlane]
table.remove(TotalPlanes, RandomPlane)
GetCurrentPlaneFunc.OnServerInvoke = function()
return SelectedPlane.Name
end
print("Plane selected: " .. SelectedPlane.Name ..
", Category: " .. SelectedPlane.Category ..
" with length of " .. SelectedPlane.Length)
ChangeUIRem:FireAllClients(SelectedPlane)
WaitLavaRem:FireAllClients(LavaRise) -- this is the remote it fires
print("Fired WaitLavaRem")
LavaRise = math.ceil(LavaRise * LavaMulti)
task.wait(3)
-- reset timer for this round
timer = 20
-- Countdown loop
while timer > 0 do
UpdateTimerRem:FireAllClients(timer, SelectedPlane)
task.wait(1)
timer -= 1
end
UpdateTimerRem:FireAllClients(0, SelectedPlane)
-- Lava tween
local TweenService = game:GetService("TweenService")
local GoalSize = Lava.Size + Vector3.new(0, LavaRise, 0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local SizeTween = TweenService:Create(Lava, tweenInfo, {Size = GoalSize})
SizeTween:Play()
end
end
-- kill players who touch lava
local function onTouch(otherPart)
local character = otherPart.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end
end
Lava.Touched:Connect(onTouch)
-- start the first round
PlayOneRound()
-- when WinRem is fired, start the next round
WinRem.OnServerEvent:Connect(function(plr)
task.wait(1)
PlayOneRound()
end)
Local Script:
local debounce = false
WaitLavaRem.OnClientEvent:Connect(function(LavaRise)
if debounce then return end
debounce = true
print("Lava Finished")
Letters.Visible = false
TextBox.Parent.Visible = false
PlaneImage.Visible = false
Category.Visible = false
GuessText.Visible = false
TimerText.Visible = false
local Info3= TweenInfo.new(
0.5,
Enum.EasingStyle.Cubic,
Enum.EasingDirection.In,
0,
false,
0
)
local Goal3 = {
Position = UDim2.new(0.337,0,-0.2,0)
}
local MoveIntermission = TS:Create(IntermissionGui.MainFrame, Info3, Goal3)
MoveIntermission:Play()
Whoosh:Play()
MoveIntermission.Completed:Wait()
IntermissionGui.MainFrame.Visible = false
-- og pos {0.337, 0},{-0, 0}
local GuessGui = player:WaitForChild("PlayerGui"):WaitForChild("GuessGUI")
if GuessGui then
print("FoundGuessGui")
GuessGui.Enabled = true
end
Lavarise.Visible = true
Lavarise.Position = UDim2.new(0.337,0,-0.2,0)
local Info = TweenInfo.new(
0.5,
Enum.EasingStyle.Cubic,
Enum.EasingDirection.In,
0,
false,
0
)
local Goal = {
Position = UDim2.new(0.337, 0, -0, 0)
}
local MoveLavaTween = TS:Create(Lavarise, Info, Goal)
MoveLavaTween:Play()
Whoosh:Play()
Lavarise.TextLabel.Text = "LAVA WILL RISE ".. LavaRise.. " BLOCKS THIS ROUND"
task.wait(3)
local Info2 = TweenInfo.new(
0.5,
Enum.EasingStyle.Cubic,
Enum.EasingDirection.In,
0,
false,
0
)
local Goal2 = {
Position = UDim2.new(0.337,0,-0.2,0)
}
local MoveLavaTween2 = TS:Create(Lavarise, Info2, Goal2)
MoveLavaTween2:Play()
Whoosh:Play()
MoveLavaTween2.Completed:Wait()
Lavarise.Visible = false
Letters.Visible = true
TextBox.Parent.Visible = true
PlaneImage.Visible = true
Category.Visible = true
GuessText.Visible = true
TimerText.Visible = true
AddTimeBTN.Visible = true
RemoveTimeBTN.Visible = true
RevealAnswerBTN.Visible = true
StealBlocksBTN.Visible = true
GuessGui.Enabled = true
debounce = false
end)
The output should say fired WaitLavaRem once, on the client it prints Lava Finished multiple times.
All help is appreciated
