Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
ghxstlvty 133
3 years ago

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

Log in to vote
0
Answered by 3 years ago
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()

0
Thats not a local script and that wasn't the problem, the button just doesn't get registerd when u press the button. vrede2 0 — 3y
Ad

Answer this question