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

Button in ScreenGui is returning nil?

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

1 comment

0

just do 'button.Name' as the argument

1 answer

✓ Accepted answer

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

2 comments

0

So basically we're able to access all the values of button? For example like button.TextColor3 and such?

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.

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