Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to fire an event from number value when the number value is changed in game?

Hi so im making a zombie game where the waves keep increasing, i use events to fire the server so I don't have to make a giant script, so how I want the waves to work is from a number value I created so everytime a zombie dies the value gets added by 1, so I basically want the zombies to be killed before each wave starts, but I have an error that the error wont show and it wont also run in this script

if Killed.Value == 4 then
	game.ReplicatedStorage.Events1.Wave2:FireServer()
end
--killed is the number value (local killed = game.Lighting,Killed)

i also tried while true do and it wouldn't work, if you know how to do this or fix this, please tell me!

3 comments

0

i think i know

0

if it doesn't work please send a model so i can try with all needed assets

0

while true do would make it so that while the value is 4, the event would fire (thats basically spamming it as long as the value is 4)

2 answers

✓ Accepted answer

You can use Value.Changed

Killed.Changed:Connect(function()
	if Killed.Value == 4 then
		game.ReplicatedStorage.Events1.Wave2:FireServer()
	end
end)

2 comments

0

The script doesnt work even with while true do... if i do while true do then it will say FireClient: player argument must be a Player object

0

When you use FireClient() you have to get a player inside the parenthesis, explaining the argument inside the parenthesis should be a player

try this:

local storage = game.ReplicatedStorage:FindFirstChild("Events1")
local event = storage:FindFirstChild("Wave2")

if Killed.Value == 4 then
    event:FireServer()
end
--killed is the number value (local killed = game.Lighting,Killed)

This discussion is preserved as it was. New answers, comments, and votes are closed.