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

How do I make my if statement work properly. Is it an FE issue?

So I'm making it when a player clicks a Gui button it fires the target player and room number to a server script and the server script checks what room number it is and would then clone it into the players backpack. But the if statement never works despite the value.

--Server Script
local roomevent = game:GetService("ReplicatedStorage").remote.roomevent
roomevent.OnServerEvent:connect(function(player, target, room)

if room == 100 then
	print("Hey there")
end




end)
--Local Script
local player = script.Parent.Parent.player.Text
local room = script.Parent.Parent.room.Text
local roomevent = game:GetService("ReplicatedStorage").remote.roomevent

script.Parent.MouseButton1Click:Connect(function()
	roomevent:FireServer(script.Parent.Parent.player.Text, script.Parent.Parent.room.Text)
end)

1 answer

✓ Accepted answer

Prefer RBXScriptSignal:Connect() with a capital C, the lowercase version is deprecated.

The problem is that you're firing a string, script.Parent.Parent.room.Text, and comparing something like "100" to 100.

Either compare room == "100" or send tonumber() of the text.

2 comments

0

oh I see i needed the "" because it's a string. the smallest of details make the difference..

0

And thank you!

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