I have 2 text buttons that have call the same remote event but request different things.
When I write in the server script just one of the two requests, it will work just fine, but when I try adding both, it’ll either run both of the scripts at the same time when I clicked only one button, or it’ll run one of the requirements when I click either button.
I would make two remote events if I needed to do only 2 commands. I need to make 100 of these, which is why I went with this route.
}
--Attempt one. When I click either of the two buttons, both prints will show in the output at the same time.
--I want it so that if I click button one, one 1 print will show, and if I hit button two, the second print will show.
Event.OnServerEvent:Connect(function()
if (Requests["Zone1Test"]) then
Requests["Zone1Test"]()
print("1 Reaced the server")
end
if (Requests["Zone2Test"]) then
Requests["Zone2Test"]()
print("2 Reaced the server")
end
end)
--Attempt two, when clicking either button, only the first print will show.
Event.OnServerEvent:Connect(function()
if (Requests["Zone1Test"]) then
Requests["Zone1Test"]()
print("1 Reaced the server")
elseif (Requests["Zone2Test"]) then
Requests["Zone2Test"]()
print("2 Reaced the server")
end
end)
If there’s any confusion, I’ll explain it more of course.
I see what you mean, but each function in the request dictionary is lead to a different part so I can’t just use the same function and define the parameter because I need the aimed part defined as well (Unless I’m able to do that with the parameter as well. I’m no good in this field so I wouldn’t know)
From the looks of it, it seems like Requests["Zone1Test"] is true which results in the first print always running. Maybe try setting that statement to false so the second print statement can print.