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

Why is this if statement with the text lable not firing the server?

if script.Parent.Text == "5" then
	
	game.ReplicatedStorage.NextLevelEvent:FireServer()
	print("server fired")
end

3 comments

1

Is this a local script?

0

yes its a local script.

0

is it not printing?

2 answers

Try this

local debounce = false

while wait() do
	if deboune == false then
		debounce = true
		if script.Parent.Text == "5" then

  			 game.ReplicatedStorage.NextLevelEvent:FireServer()
  			 print("server fired")
	
			wait(3) -- The amount of time until it fires again
			debounce = false
		end
	end
end

1 comment

0

That would error, you are firing it too many times

I'm sure this should work, what it does is whenever the text is changed, it will check if the text is "5" and if it's 5 then it will fire the event.

script.Parent:GetPropertyChangedSignal("Text"):Connect(function() -- when text is changed
	if script.Parent.Text == "5" then
		
		game.ReplicatedStorage.NextLevelEvent:FireServer()
		print("server fired")
	end
end)

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