What I’m trying to do is make it so that when a remote event is fired, it starts to slowly decrease the player’s health overtime. I have no idea why it’s not working. All help is appreciated! This is a server script in StarterCharacterScripts.
local enabled = false game.ReplicatedStorage["207"].OnServerEvent:Connect(function() enabled = true print(enabled) end) while wait(1) do print("Check") if enabled == true then script.Parent.Humanoid.Health -= 1 end end
maybe try putting script into the serverscriptservice or workspace and then do that
game.Players.PlayerAdded:Connect(function(player) -- function runs when a player joins the game local enabled = false game.ReplicatedStorage["207"].OnServerEvent:Connect(function() enabled = true print(enabled) end) while wait(1) do print("Check") if enabled == true then if player.Character.Humanoid ~= nil then --checking if player character exists player.Character.Humanoid = player.Character.Humanoid - 1 end end end end)
this script worked for me, comment or dm me on discord (erky?#2264) if you will have any problems