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

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

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.

0
oh I see i needed the "" because it's a string. the smallest of details make the difference.. VeryDarkDev 47 — 6y
0
And thank you! VeryDarkDev 47 — 6y
Ad

Answer this question