What's a good way of enabling a script by player?

what’s a good way of enabling a script by player?

i tried

local TextButton = script.Parent

TextButton.MouseButton1Click:Connect(function()
script.Parent.Visible = false
game.StarterGui.ScreenGui.Frame.TextLabel.Script.Disabled = false
game.StarterGui.ScreenGui.Frame.TextLabel.Visible = true

end)

but it won’t work. any alternatives

note: im trying to make a start button.

1 Like

do this for PlayerGui not StarterGui.

i dont see that in my workspace

PlayerGui is an instance under the player. Like this:
game.Players.Wseall_UTUBE.PlayerGui

It’s not something in the workspace. It is under the player. ex: player.PlayerGui

It might’ve not worked because you have one Parent instead of two before the .Visible = false

the script i want to active is still located in ScreenGui though

If my calculations are correct, then this should work:

local TextButton = script.Parent
local Frame = TextButton.Parent

TextButton.MouseButton1Click:Connect(function()
	TextButton.Visible = false
	Frame.TextLabel.Script.Disabled = false
	Frame.TextLabel.Visible = true
end)

If not, then show me a screenshot of locations of both the button and the TextLabel.

Yes, but you what you are trying to activate is not under the player, therefore meaning that it won’t affect the player.

When a player joins, all the things that are in the StarterGui will be replicated into each individual player’s PlayerGui. So you need to replace your code with this:

local TextButton = script.Parent
local Player = game.Players.LocalPlayer

TextButton.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
	Player.PlayerGui.ScreenGui.Frame.TextLabel.Script.Disabled = false
	Player.PlayerGui.ScreenGui.Frame.TextLabel.Visible = true
end)

the script still doesn’t work…

Try this:

local p = script.Parent
local g = game.Startgui.ScreenGui.Frame

p.MouseButton1Click:Connect(function()
p.Parent.Visible = false
g.TextLabel.Visible = true
g.TextLabel.Script.Disabled = false
end)

Also make sure it’s a local script

check the script, it still doesn’t work. its like roblox blocked unlocking scripts by code

Can you send me the location (picture) of the TextLabel and TextButton? I tried telling you that earlier, but my message went through for moderation…

Are there more than one Frame and/or TextLabel, having two of the same makes the lua script not work.

Did you use my solution from the post above?

its in starter gua.frame.text button next to text lable. script

Do you have the frame in a ScreenGui?

doesnt activate the script for the game

yes i do have the frame in a ScreenGui