Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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!

0
i think i know tommymcoco1 39 — 3y
0
if it doesn't work please send a model so i can try with all needed assets tommymcoco1 39 — 3y
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) Omq_ItzJasmin 666 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

You can use Value.Changed

Killed.Changed:Connect(function()
    if Killed.Value == 4 then
        game.ReplicatedStorage.Events1.Wave2:FireServer()
    end
end)
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 Bluejay20000 -11 — 3y
0
When you use FireClient() you have to get a player inside the parenthesis, explaining the argument inside the parenthesis should be a player Omq_ItzJasmin 666 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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)

Answer this question