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)
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.