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

The event in my script isn't working correctly?

Asked by
walvie 12
4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
Filipalla 504 Moderation Voter
4 years ago
Edited 4 years ago

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) :)

0
Just needed to add :WaitForChild("FirstScreen") for it to work. Thank you. walvie 12 — 4y
0
np Filipalla 504 — 4y
Ad

Answer this question