So after realizing that you cannot use LocalPlayer inside of a normal script, I don't know how to go about doing this. Basically what this script is supposed to do is this: -A player touches a certain part/brick -A store gui which is located inside the player's PlayerGui opens (ShopGui1.Frame.Visible = true) -If the player stops touching the part, the gui closes (ShopGui1.Frame.Visible = false) This is what I had:
--Opens the store gui function onTouch(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human then game.Players.LocalPlayer.PlayerGui.ShopGui1.Frame.Visible = true script.Parent.TouchEnded:connect(endTouch) end end --Closes the store gui function endTouch() game.Players.LocalPlayer.PlayerGui.ShopGui1.Frame.Visible = false end script.Parent.Touched:connect(onTouch)
This might work.
Basically, I've used :GePlayerFromCharacter
to get the player of whoever touched the brick.
Should work, but I haven't tested it as I am in college.
script.Parent.Touched:connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) if Player then Player.PlayerGui.ShopGui1.Frame.Visible = true end end end) script.Parent.TouchEnded:connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) if Player then Player.PlayerGui.ShopGui1.Frame.Visible = false end end end)