game.ReplicatedStorage.Event.TSDamage.OnInvoke = function() if game.ReplicatedStorage.Event.InUse.Value == true then for i, Humans in pairs (game.Workspace:GetChildren()) do if Humans:FindFirstChild("Humanoid") then hum = Humans:FindFirstChild("Humanoid") oldhealth = hum.Health oldmax = hum.MaxHealth hum.MaxHealth = math.huge hum.Health = math.huge end end end end game.ReplicatedStorage.Event.AfterTS.OnInvoke = function() if game.ReplicatedStorage.Event.InUse.Value == false then for i, Humans in pairs (game.Workspace:GetChildren()) do if Humans:FindFirstChild("Humanoid") then hum = Humans:FindFirstChild("Humanoid") hum.MaxHealth = oldmax hum.Health = oldhealth end end end end
what this does is that when an event is fire, it basically remembers all the players' health and then sets their health to infinity. and then once the second health is fired, the players' health is reverted back to normal. whats happening here is that the first event is being repeated loads of times so that the script remembers the players infinite health instead of the original one so when the second event is fired, the players' health is still infinity and not reverted.
F key script
local input = game:GetService("UserInputService") local player = game.Players.LocalPlayer input.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.F then game.ReplicatedStorage.Event.TimeStopEvent:FireServer() if game.ReplicatedStorage.Event.InUse.Value == false then for i = 70, 200, 5 do wait() workspace.Camera.FieldOfView = i end for i = 200, 70, -5 do wait() workspace.Camera.FieldOfView = i end end else end end)
Alright, actually you don't need to post the F key script, I'll just give you some example codes.
I believe why this is happening is because when the player presses the "F" key, the input is captured multiple times at once. To solve this, you just need to add a debounce.
It will look something like this:
local uis = game:GetService("UserInputService") local F_KeyPressed = false -- This is called a debounce uis.InputBegan:Connect(function(input) if ((input.KeyCode == Enum.KeyCode.F) and (F_KeyPressed == false)) then F_KeyPressed = true -- Fire the events wait(2) -- You can change to whatever value you like F_KeyPressed = false end end)
NOTE: The codes above are not tested, I'm just giving an example.
A debounce ensures that the "F" key can only be pressed after a certain timing.
Also, you are using a remote function, therefore, you will need to return something by using the “return” keyword. Otherwise, the codes will not continue to run until you return one. (Other than the debounce problem, this is one of the problems too)
I found the issue. I invoked the BindableEvent lots of times because it was under the "for" loop. So i just moved it above the loop and it worked.