My touched event is supposed to open a gui. At first it opened for everyone when its supposed to open only for the player who touched it. So I edited it and now its broken. Whats wrong?
local UpgradePart = script.Parent
UpgradePart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = hit.Parent.Parent
player.PlayerGui.UpgradesShop.MainFrame.Visible = true
else
return nil
end
end)

6 comments
I already gave you an answer, but basically you should get the player with GetPlayerFromCharacter. Because what you did is get the players Character s Parent , wich is workspace but the PlayerGui isnt in workspace but in the Player intself.
true
true
true
true
If you teying to make a gui show up when touching a part, I advice you on watching AlvinBlox video talking about it https://youtu.be/6r_PBSXzOmI