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

TextButton is not calling function?

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)

1 comment

0

Just tried it and it worked perfectly. Thanks for the help!

1 answer

✓ Accepted answer

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)

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