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

Why isn't this script working? It's not registering that this SurfaceGui button is clicked.

Script parented to the text that is suppose to change from Unclaimed to Claimed once the SurfaceGui button is clicked:

local Claimed = script.Parent;
local Frame = Claimed.Parent;
local ClaimRemote = Frame:WaitForChild("RemoteEvent");

ClaimRemote.OnServerEvent:Wait();
print("fired")
Claimed.Text = "Status: Claimed";

Local Script that is parented to StarterPlayerScripts:

local ThingInWorkspace = game.Workspace.OrderBoard.Part.SurfaceGui

local function ConnectEvent(Gui)
     local Claim = Gui:WaitForChild("TextButton")
	    local Connection = nil;
	print("aldiemejoost;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")
	    Connection = Claim.Activated:Connect(function()
		print("clicked")
        Connection:Disconnect();
        Gui.RemoteEvent:FireServer();
    end);
end

for _, Gui in ipairs(ThingInWorkspace:GetChildren()) do
    ConnectEvent(Gui);
end

ThingInWorkspace.ChildAdded:Connect(function(Obj)
	    if (Obj.Name == "_example") then
        ConnectEvent(Obj);
    end
end);

(Don't mind some of the print statements we were just trying to test it lmao)

We also have the RemoteEvent parented in the order board.

1 answer

local Claimed = script.Parent;
	local Frame = Claimed.Parent;
	local ClaimRemote = Frame:WaitForChild("RemoteEvent");
	 
	ClaimRemote.OnServerEvent:Wait();
	print("fired")
	Claimed.Text = "Status: Claimed";

You don't need to fire to the server to change the client's guis. Just do it directly from the local script. If you want to change it for every client then try using :FireAllClients()

1 comment

0

Thats not a local script and that wasn't the problem, the button just doesn't get registerd when u press the button.

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