game.Workspace["Shop"]:WaitForChild("buy").Touched:connect(function(player)
if player.Parent:FindFirstChild("Humanoid") then
local playername = game:GetService("Players"):FindFirstChild(player.Parent.Name)
if playername.PlayerGui:FindFirstChild("shop").Frame.Visible == false and playername.PlayerGui:FindFirstChild("AnimShop").Frame.Visible == false then
playername.PlayerGui:FindFirstChild("shop").Frame.Visible = true
end
end
end)
This script is supposed to make the gui visible when a player touches a brick called "buy". It works perfectly in studio but not in game. How can I fix this?

2 comments
put it into a local script
i tried to put it in a localscript but it wasn't working?