Script not working

Hey so I am trying to make it so when you click on a tool a script enables can anyone tell me why this script isn’t working?

local tool = script.Parent

tool.Activated:Connect(function()
		script.Parent.Parent.Parent.StarterGui.ScreenGui2.TextLabel.ERERER.Disabled = false
		wait(4)
		script.Parent.Parent.Parent.StarterGui.ScreenGui2.TextLabel.ERERER.Disabled = true
end)

		


Ty!

1 Like

Btw I am new to scripting
Probably obvious though.

2 Likes

Make it a script.

local tool = script.Parent
local plr = script.Parent.Parent.Parent

tool.Activated:Connect(function()
	plr:WaitForChild("PlayerGui").ScreenGui2.TextLabel.ERERER.Disabled = false
	wait(4)
	plr:WaitForChild("PlayerGui").ScreenGui2.TextLabel.ERERER.Disabled = true
end)

2 Likes

The problem is script.Parent.Parent.Parent.StarterGui won’t lead to the player. It just leads to an error: StarterGui is not a valid member of Character.Name.

You didn’t add a player variable and look in PlayerGui for the Gui, which you can do by local plr = script.Parent.Parent.Parent (since local tool = script.Parent)

plr:WaitForChild("PlayerGui").GuiName -- action, action.

2 Likes

You’re trying to find the StarterGui in the Character. When a tool is activated it is in the player’s Character, as they are holding it.

1 Like