I am trying to make SurfaceGUI script that shows a GUI to someone who clicked it. I am trying to stock who clicked it with playerWhoClicked. Here's the script
Please ignore the massive amount's of Parent's.
script.Parent.MouseButton1Down:connect(function(playerWhoClicked) groupid = game.Workspace.GroupID.Value player = game.Player:getPlayerFromCharacter(playerWhoClicked) if player then gui = player.PlayerGui["EditBoard " ..script.Parent.Parent.Parent.Parent.Parent.Parent.Room.Value] if player:IsInGroup(groupid) and player:RoleInGroup(groupid) >=3 then if gui.Background.Visible == false then gui.Background.Visible = true else gui.Background.Visible = false end end end end) script.Parent.MouseButton1Down:connect()
ERROR:
Line 3
Player is not a valid member of DataModel
Can anyone give me a new way to receive who clicked it?
1. You said game.Player
not game.Players
2. MouseButton1Down()
returns the x and y coordinates of the mouse.
Unfortunately you can't get the player by MouseButton1Down.
BUT you can get it by going through the PlayerGui.
So you can say:
script.Parent.MouseButton1Down:connect(function() groupid = game.Workspace.GroupID.Value player = script.Parent.Parent.Parent.Parent.Parent --button>frame>screengui>playergui>player if player then gui = player.PlayerGui["EditBoard " ..script.Parent.Parent.Parent.Parent.Parent.Parent.Room.Value] if player:IsInGroup(groupid) and player:RoleInGroup(groupid) >=3 then if gui.Background.Visible == false then gui.Background.Visible = true else gui.Background.Visible = false end end end end)