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 ObjectValue?

Asked by 8 years ago

I understand that it is not a valid member but it's an if then statement Line 37

Part=workspace.DanceClub.Interactions.Queue
Queue=game.ServerScriptService.DanceClub.Values.Queue

Players=Queue:GetChildren()
b=nil
current=0

function Update(new)
    b=new.Name
Players=Queue:GetChildren()


if #Players > current then
       current=#Players
    for i,v in next ,Players do
        local Gui=game.Players[v].PlayerGui.DDR.Queue
        Gui:GetChildren()
---WIP----      
    end end
if #Players < current then
    current=#Players
    for i,v in pairs(Players) do
        local Gui=game.Players[v].PlayerGui.DDR.Queue
        local re=Gui:findFirstChild(""..b)
        re.Parent:remove()

            for i,v in next(Gui) do
            if v:IsA("Frame") then
                if v.Position.Y.Scale>0 then
                    v.Position=UDim2.new(0,0,v.Position.Y.Scale-0.13,0)

    end end end end end 

Part.ClickDetector.MouseClick:connect(function(plr)
Players=Queue:GetChildren()
if Queue[plr.Name]==nil then
----- Error Starts Above ^^^^^^^^^^^^^^^^^6


local Gui=game.Players[plr.Name].PlayerGui
local DDR=game.ServerScriptService.DanceClub.Guis.DDR:Clone()
local z=Instance.new("NumberValue",Queue)
z.Name=""..plr.Name
DDR.Parent=Gui
DDR.Queue.Visible=true 

local number=0
for i,v in next(Players) do
    print(v)
    local Frame=game.ServerScriptService.DanceClub.Guis.Player:clone()
    Frame.Name=""..v
    Frame.Parent=DDR.Queue
    Frame.PlayerName.Text=""..v
    Frame.Position=UDim2.new(0,0,0.13*number,0)
    Frame.Visible=true

    number=number+1 end

end
 Update(plr)
end)

Queue.ChildAdded:connect(function(plr)
    Update(plr)

end)
Queue.ChildRemoved:connect(function(plr)
    Update(plr)

end)
0
Can you post a picture of the ancestry of Queue? BlackJPI 2658 — 8y

1 answer

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

The statement if Queue[plr.Name]==nil then is asking for an error. If it isn't nil, it will be false. If it is nil, it will error because you are trying to directly index a game object that does not exist. You need to use FindFirstChild to solve that:

if not Queue:FindFirstChild(plr.Name)then

Ad

Answer this question