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

How do i fix my clickdetector for gui script that wont work?

im using clickdetector inside brick, it has a normal script inside:

script.Parent.ClickDetector.MouseClick:Connect(function(p)
	if p.Character.Masked.Value == true then
		if p.Character.Bag.Value == false then
		print("Stolen")
		--give bag to character
		p.Character.Bag.Value = true
		script.Parent.Parent:Destroy()
		elseif p.Character.Bag.Value == true then
		p.PlayerGui.bagwarning.Enabled = true
		wait(1)
		p.PlayerGui.bagwarning.Enabled = false
		end
	end
end)

i also tried

script.Parent.ClickDetector.MouseClick:Connect(function(p)
	if p.Character.Masked.Value == true then
		if p.Character.Bag.Value == false then
		print("Stolen")
		--give bag to character
		p.Character.Bag.Value = true
		script.Parent.Parent:Destroy()
		elseif p.Character.Bag.Value == true then
		p.PlayerGui["bagwarning"].Enabled = true
		wait(1)
		p.PlayerGui["bagwarning"].Enabled = false
		end
	end
end)

and supposedly the (p) is the player that clicks it which is me, and i even CHECKED for that screen gui, the name IS correct, but it doesnt work and output says:

bagwarning is not a valid member of PlayerGui

please help :()

2 comments

0

simple, is bagwarning actually a valid member of PlayerGui? check it manually

0

THATS EXACTLY WHAT I SAID, I CHECKED AND ITS THERE!

1 answer

From what I know, a normal script can't access the playergui due to filtering enabled. You would have to use a remote event, from the server to the client, to disable/enable the GUI. https://developer.roblox.com/articles/Remote-Functions-and-Events

Or, you could also simply change the script to a local script. That should fix it, unless there is an error elsewhere.

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