Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Button in ScreenGui is returning nil?

Asked by 2 months ago

I'm messing around with RemoteEvents at the moment, trying to get a better understanding of how it works. But I don't exactly understand why button is returning nil?

Local Script

local button = script.Parent

button.MouseButton1Click:Connect(function()
    print(button)
    game:GetService("ReplicatedStorage").TestEvent:FireServer(button)

end)

Server

local repStorage = game:GetService("ReplicatedStorage")
local event = repStorage:WaitForChild("TestEvent")

event.OnServerEvent:Connect(function(player, button)
    print(player, button)
end)

The output is Player1 nil

0
just do 'button.Name' as the argument EXpodo1234ALT 1322 — 2mo

1 answer

Log in to vote
0
Answered by 2 months ago

It is returning nil because the player gui is not accessible by the server. You can, however fire it with the button's name (button.Name).

0
So basically we're able to access all the values of button? For example like button.TextColor3 and such? Icy_Qube 29 — 2mo
0
GUIs inside of the PlayerGui folder are cloned locally. The server isn't, and shouldn't be, touching GUIs anyway. And the PlayerGui folder is created by the server. incapaxian 1447 — 2mo
Ad

Answer this question