Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player is not a valid member of DataModel??

Asked by 9 years ago

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?

0
What line is the error on? Muoshuu 580 — 9y
0
Line 3, Forgot that part. KnownDev 0 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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)
0
The gui is a Surface GUI. Will it still work that way? KnownDev 0 — 9y
0
Yes sir. XtremeSpy 80 — 9y
Ad

Answer this question