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

TextButton is not calling function?

Asked by 6 years ago

Hello, I am making a script that will fire a RemoteEvent when clicked. However, the remote event is not being fired as the script on the other end is not doing what it is supposed to do. I put a print command in the function, and it is not showing up in the console. The script is a LocalScript and is in the StarterGui.

The script:

game.StarterGui.Main.SelectWeapon.AK47.MouseButton1Click:connect(function()
    --AK47
    print("Button Clicked")
    selectionEvent:FireServer(player, "Primary", 1)
end)
0
Just tried it and it worked perfectly. Thanks for the help! reddarkness321 14 — 6y

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

The GUIs are in the PlayerGui, not the StarterGui. The StarterGui is what gets replicated to each player.

Put this inside the TextButton

script.Parent.MouseButton1Click:Connect(function()
    --AK47
    print("Button Clicked")
    selectionEvent:FireServer(player, "Primary", 1)
end)
Ad

Answer this question