hello! I am trying to code a game with a shop that opens when you stand on a brick. Whenever I try this it tells me that 'ScreenGui is not a valid member of PlayerGui', which I can confirm it is. Here is my script Below. Thank you anyone who helps me :D
script.Parent.Touched:connect(function(hit)
local humanoid=hit.Parent:FindFirstChild("Humanoid")
if humanoid ~=nil then
local user = hit.Parent.Name
local ScreenGui = game.Players[user].PlayerGui:FindFirstChild("ScreenGui")
local frame = ScreenGui:FindFirstChild("UpgradesFrame")
game.Players[user].PlayerGui[ScreenGui][frame].Visible = true
end
end)
P.S I have tried just doing game.Players[user].PlayerGui.ScreenGui.. but still doesn't work. WaitForChild doesn't work either '-'

3 comments
Is this a server script?
^ if so use an event
If its not you're referencing the player incorrectly, if so you need to use an event, like professor said.