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

Can't access playerGUI with filtering enabled?

I cannot access the playerGUI through a local script or a normal script with filtering enabled on. When the ClickDetector detects a click it is supposed to get the player and change some stats in a GUI but also make it so other players cannot interact with the item.

owner=script.Parent.Configuration.owner
name=script.Parent.Configuration.name

script.Parent.ClickDetector.MouseHoverEnter:connect(function(player)
	script.Parent.info.Enabled=true
end)
script.Parent.ClickDetector.MouseHoverLeave:connect(function(player)
	script.Parent.info.Enabled=false
end)

script.Parent.ClickDetector.MouseClick:connect(function(player)
	if(owner.Value=="No One!")then
		owner.Value=player.Name
		script.Parent.pop.Playing=true
	elseif(owner.Value ~= player.Name)then
		script.Parent.info.main.owner.TextColor3=Color3.new("New yeller")
		script.Parent.info.main.owner.Text="Not yours!"
		script.Parent.error.Playing=true
		wait(script.Parent.error.TimeLength*2)
		script.Parent.info.main.owner.Text=owner.Value
	elseif(owner.Value==player.Name)then
		local inv=player.PlayerGui.HUD.inventory
		if((inv.a1.inUse.Value==false or inv.a1.pID.Value==script.Parent.pID.Value) and inv.a1.limReach.Value==false)then
			inv.a1.inUse.Value=true
			inv.a1.amount.Value=inv.a1.amount.Value+1
			inv.a1.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			local clone=script.Parent.Parent:Clone()
			script.Parent.Parent:Destroy()
		elseif(inv.a2.inUse.Value==false or inv.a2.pID.Value==script.Parent.pID.Value and inv.a2.limReach==false)then
			inv.a2.inUse.Value=true
			inv.a2.amount.Value=inv.a2.amount.Value+1
			inv.a2.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy() 
		elseif(inv.a3.inUse.Value==false or inv.a3.pID.Value==script.Parent.pID.Value and inv.a3.limReach==false)then
			inv.a3.inUse.Value=true
			inv.a3.amount.Value=inv.a3.amount.Value+1
			inv.a3.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.a4.inUse.Value==false or inv.a4.pID.Value==script.Parent.pID.Value and inv.a4.limReach==false)then
			inv.a4.inUse.Value=true
			inv.a4.amount.Value=inv.a4.amount.Value+1
			inv.a4.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.a5.inUse.Value==false or inv.a5.pID.Value==script.Parent.pID.Value and inv.a5.limReach==false)then
			inv.a5.inUse.Value=true
			inv.a5.amount.Value=inv.a5.amount.Value+1
			inv.a5.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.a6.inUse.Value==false or inv.a6.pID.Value==script.Parent.pID.Value and inv.a6.limReach==false)then
			inv.a6.inUse.Value=true
			inv.a6.amount.Value=inv.a6.amount.Value+1
			inv.a6.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.b1.inUse.Value==false)then
			inv.b1.inUse.Value=true
			inv.b1.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.b2.inUse.Value==false)then
			inv.b2.inUse.Value=true
			inv.b2.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.b3.inUse.Value==false)then
			inv.b3.inUse.Value=true
			inv.b3.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.b4.inUse.Value==false)then
			inv.b4.inUse.Value=true
			inv.b4.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.b5.inUse.Value==false)then
			inv.b5.inUse.Value=true
			inv.b5.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent.Parent:Destroy()
		elseif(inv.b6.inUse.Value==false)then
			inv.b6.inUse.Value=true
			inv.b6.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.c1.inUse.Value==false)then
			inv.c1.inUse.Value=true
			inv.c1.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.c2.inUse.Value==false)then
			inv.c2.inUse.Value=true
			inv.c2.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.c3.inUse.Value==false)then
			inv.c3.inUse.Value=true
			inv.c3.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.c4.inUse.Value==false)then
			inv.c4.inUse.Value=true
			inv.c4.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.c5.inUse.Value==false)then
			inv.c5.inUse.Value=true
			inv.c5.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.c6.inUse.Value==false)then
			inv.c6.inUse.Value=true
			inv.c6.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.d1.inUse.Value==false)then
			inv.d1.inUse.Value=true
			inv.d1.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.d2.inUse.Value==false)then
			inv.d2.inUse.Value=true
			inv.d2.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.d3.inUse.Value==false)then
			inv.d3.inUse.Value=true
			inv.d3.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.d4.inUse.Value==false)then
			inv.d4.inUse.Value=true
			inv.d4.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.d5.inUse.Value==false)then
			inv.d5.inUse.Value=true
			inv.d5.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.d6.inUse.Value==false)then
			inv.d6.inUse.Value=true
			inv.d6.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.h1.inUse.Value==false)then
			inv.h1.inUse.Value=true
			inv.h1.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.h2.inUse.Value==false)then
			inv.h2.inUse.Value=true
			inv.h2.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.h3.inUse.Value==false)then
			inv.h3.inUse.Value=true
			inv.h3.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.h4.inUse.Value==false)then
			inv.h4.inUse.Value=true
			inv.h4.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.h5.inUse.Value==false)then
			inv.h5.inUse.Value=true
			inv.h5.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.h6.inUse.Value==false)then
			inv.h6.inUse.Value=true
			inv.h6.pID.Value=script.Parent.pID.Value
			script.Parent.collect.Playing=true
			wait(script.Parent.collect.TimeLength)
			script.Parent:Destroy()
		elseif(inv.full.Value==true)then
			script.Parent.info.main.owner.Text="Inventory Full!"
			wait(0.75)
			script.Parent.info.main.owner.Text=script.Parent.Configuration.owner.Value
		end
	end
end)

while true do
	wait()
	owner.Changed:connect(function()
		script.Parent.info.main.owner.Text=owner.Value
	end)
end

How do I do this when some stuff will work with filtering enabled on and some won't.

2 comments

0

You might need to pass the PlayerGui through the remote event so that your serverscript can access it that way. If that dont work then try using wait for PlayerGui() or WaitForChild()

0

You should also be able to reduce most of the code into a loop or function so that you don't have to repeat the same code multiple times. The while loop at the end is also not required, as you can just use the function.

1 answer

You should always be able to access the PlayerGui through a script & a local script.

For a local script:

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

For a server script (with a click detector):

clickDetector.MouseClick:connect(function(player)
	local playerGui = player:WaitForChild("PlayerGui")
end)

You might be having trouble finding the items in the player gui - If you're using FilteringEnabled, things created on the client are NOT replicated to the server, so if you are trying to find a GUI created by a local script in the Player's Gui, then you can only do that with local script.

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