When a certain boolean value is equal to true, I want all players in the server to take damage every 5 seconds and a gui to appear for a split second. I have this script, I do not know what's wrong with it and in the output, there are no errors that appear. I tried some other stuff, including for loops but it didn't work, I don't understand them well tho so if you are using for loops, I would appreciate if you explained in detail what stuff does, thanks :3
Here's the script:
--Variables
local bulb = script.Parent
local stageone = bulb.Stage1
local StarterGUI = game.StarterGui
local DmgGUI = StarterGUI.BulbDmgGUI
local Players = game:GetService('Players')
--Code
Players.PlayerAdded:Connect(function(plr)
local char = plr.Character
if char == true then
local humanoid = char:FindFirstChild('Humanoid')
while bulb.Stage1.Value == true do
print('hi')
StarterGUI.BulbDmgGUI.Enabled = true
humanoid:TakeDamage(10)
wait(.2)
StarterGUI.BulbDmgGUI.Enabled = false
wait(5)
end
end
end)
This code is all in a Server Script. Thanks again ^^

1 comment
Why are you checking if character is true, that will always be false