✓ Accepted answer
You can’t get the local player on a server script. A server script is just a regular script.
You can get the player within the touched event by calling a function :GetPlayerFromCharacter()
A character is just the interactive and visual appearance of the player, like the hats, the shirts and everything else. Whenever a character touches a brick only their body parts (head, torso, right arm) will be seen as “touched”.
To get a player from the character you get the character which is part.Parent. You can store it in a variable too. You also need to check if “part” is actually part of the parent. I included that for you.
Your script fixed will be:
function onTouched(part)
if part.Parent:FindFirstChild(“Humanoid”) then
local Player = game.Players:GetPlayerFromCharacter(part.Parent)
Player.PlayerGui.GameGui.SwordShop1.Visible = true
end
end
script.Parent.Touched:connect(onTouched)
3 comments
Where'd you get these quotation marks? “”
I have no idea.
holy you are right, it's probably a rare bug