Script won't fire client

image
I made a script that gives a countdown, and when the countdown reaches 0 then it fires an event.

But the script won’t work because I’m assuming at the bottom there’s an error line at the word ‘end’. This is what it says in the output

image

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.RemoteEvents
local Event = RemoteEvents.Hollow


while true do
		script.Parent.Text = script.Parent.Text -1
end
	


	wait(1)
	if script.Parent.Text == "0" then 
	Event:FireClient 
	

	end
1 Like

Event:FireClient by itself won’t work. You have to define the player and do this

Event:FireClient(player)

Or if you want to fire all clients, you would do

Event:FireAllClients()

Also, as the people mentioned below, use a for loop instead.

1 Like

you had some errors and you have to specify which “player” to fire. (every player has their own client)
also you can’t perform math operations on TEXT.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.RemoteEvents
local Event = RemoteEvents.Hollow


while true do
    someNumber = someNumber - 1
    script.Parent.Text = someNumber
    wait(1)
    if script.Parent.Text == "0" then 
        Event:FireClient(player) -- FIRE A CERTAIN PLAYERS CLIENT
    end
end

Please do not directly do arithmetic on the Text property and please do not post screenshots of code. You are missing parentheses to call the function. LocalScripts cannot call RemoteEvent::FireClient either.

I am not sure where you start from so do it like this.

for i = 10, 0, -1 do
    script.Parent.Text = i
    wait(1)
end

-- Code that will execute when the text is equal to 0

Event:FireClient

It should be Event:FireClient() instead, where you can add more arguments inside the parenthesis.

If you apply this change, this function will never be triggered though, since you are never breaking the while loop at the beginning of the code. Use a numeric for loop instead for the countdown; for example:

local num = script.Parent.Text
for i = num, 0, -1 do
    script.Parent.Text = i
end
--Event:FireClient()
1 Like