Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Player is not a valid member of DataModel??

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?

2 comments

0

What line is the error on?

0

Line 3, Forgot that part.

1 answer

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)

2 comments

0

The gui is a Surface GUI. Will it still work that way?

0

Yes sir.

This discussion is preserved as it was. New answers, comments, and votes are closed.