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

The event in my script isn't working correctly?

I am making a basic script were if you press a TextButton, your player will be able to move again. It's a local script and everything in the event isn't working the rest works fine. I get no error in the output and the print isn't printing.

local module = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local controls = module:GetControls()
local button = game.StarterGui.FirstScreen.PlayButton

controls:Disable()

button.Activated:Connect(function()
	controls:Enable()
	button.Parent.Enabled = false
	print("button pressed")
end)

I have tried changing the Activated event to MouseButton1Click but the result are the same.

1 answer

✓ Accepted answer

Each time a player joins the game the StarterGui's contents are cloned into that player's PlayerGui. The PlayerGui is the GUI that is displayed to the player, therefore it should be like this

local button = game:GetService("Players").LocalPlayer.PlayerGui.FirstScreen.PlayButton

You can read more about PlayerGui here

Don't forget to mark my answer as the solution if it solved your problem(Upvotes are also really appreciated) :)

2 comments

0

Just needed to add :WaitForChild("FirstScreen") for it to work. Thank you.

0

np

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