Shop GUI block issue

The script should bring a frame when you step, and make it go away when you step off. Why is it not working?

local shopframe = game.StarterGui.ShopInGame.ShopFrame
script.Parent.Touched:Connect(function()
	shopframe.Visible = true
end)

script.Parent.TouchEnded:Connect(function()
	shopframe.Visible = false
end)
1 Like

You are defining your UI with game.StarterGui. UIs are cloned to the PlayerGui, they are not in the StarterGui.

PlayerGui (roblox.com)

1 Like

Will this work?

local plr = game.Players.LocalPlayer
local shopframe = plr.PlayerGui.ShopInGame.ShopFrame
script.Parent.Touched:Connect(function()
	shopframe.Visible = true
end)

script.Parent.TouchEnded:Connect(function()
	shopframe.Visible = false
end)

Yes, but first you can’t have a LocalScript inside a part in workspace. They won’t run in workspace. Second, you have to check to make sure the part touching the “script.Parent” object is the player. Also, don’t use the TouchEnded event because it’s not reliable for this purpose. Use a radius and looped distance check instead, or create a hitbox part so the events will not fire due to the player idle animation.

Just add a debounce between the the beginning and the ending of each scopes. If that doesn’t solve the problem, just show us the error if it throws you an error.

A debounce is a good idea, but that will not fix the script. It needs to be placed in PlayerGui or StarterPlayerScripts