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

When I press my GUI Button, nothing activates?

Asked by 3 years ago
Edited 3 years ago

Code:

local button = script.Parent

local Plrs = game:GetService("Players")

local rs = game:GetService("ReplicatedStorage")
local remote = rs:WaitForChild("toRemote")

Plrs.PlayerAdded:Connect(function(player)
    script.username.Value = player.Name
end)

local char = game.Workspace:WaitForChild(script.username.Value)
local plr = Plrs:GetPlayerFromCharacter(char)

button.MouseClick:Connect(function()
    print("Done!")
    remote:FireClient(game.Players:FindFirstChild(plr))
    print("Done!")
end)

When I press the button, nothing happens. It doesn't print "Done!" either time, and I am very confused. Any help is appreciated.

0
please use a code block botw_legend 502 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

Use :MouseButton1Click instead of :MouseClick. MouseClick isn't a property of any GuiObject.

0
Thanks! It works now NOT_NovaFox 0 — 3y
Ad

Answer this question