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

Why am I getting "Shop is not a valid member of PlayerGui"?

Okay so, the hiearchy for my GUI is Players > PlayerGui > Shop > Frame > ScrollingFrame > TextButton

In that textbutton I have a script that is to fire a RemoteEvent

local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Coins
local itembutton = script.Parent--- MAIN BUTTON
local desc = script.Parent.Parent.Parent.Desc
local indextext = script.Parent.Text  
Open = false


itembutton.MouseButton1Click:connect(function()
game.ReplicatedStorage.RemoteServer.RemoteEvent:FireServer()
end)

This is the line in the RemoteServer that the output is complaining about

script.RemoteEvent.OnServerEvent:connect(function(player)
local itembutton = player.PlayerGui.Shop.Frame.ScrollingFrame.hp
end)

This is 100% CORRECT as I have checked the explorer, is it not able to access it for some reason?

1 answer

With FilteringEnabled, Scripts don't have access to objects in the PlayerGui that came from the StarterGui or from LocalScripts.

Hence, on the server, there is no Shop. You can confirm this by looking at the player in a Test Server.

Any input that the server needs should be sent along in the RemoteEvent/RemoteFunction.

Changes to GUIs should be done by the LocalScript, possibly using the result of a RemoteFunction or using OnClientEvent with a RemoteEvent.

1 comment

0

Hmm, this stinks. What I wanted to happen was that I have an if statement in the RemoteServer script that checks conditions if a player can purchase an item in the virtual store. If he can, I wanted the GUI text to say "Purchased" and if not for it say something like "error". I know how to code that and the code is already there in the RemoteServer script but because of FilteringEnabled I can't

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