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

Attempt to connect failed: Passed value is not a function?

Asked by 10 years ago

So, I tryed making a script what displays a rank above their head. Some strange reason. It does not work. Error:

Any help? :) Thanks.

Attempt to connect failed: Passed value is not a function
Script 'Workspace.Overhead Ranks', Line 4

Script:

groupid = 1123228
groupn = "LavaBlast Security Group" 

game.Players.PlayerAdded:connect(onPlayerRespawned)
function onPlayerRespawned(newPlayer)
    wait(1)
    if newPlayer:IsInGroup(groupid) then
        guigroup=Instance.new("BillboardGui")
        guigroup.Parent=newPlayer.Character.Head
        guigroup.Adornee=newPlayer.Character.Head
        guigroup.Size=UDim2.new(4,0,2,0)
        guigroup.StudsOffset=Vector3.new(0,3,0)
        textgroup=Instance.new("TextLabel")
        textgroup.Size=UDim2.new(1,0,1,0)
        textgroup.BackgroundTransparency = 1
        textgroup.TextColor3 = Color3.new(255/255, 255/255, 255/255)
        textgroup.TextStrokeTransparency = 0
        textgroup.TextTransparency = 0
        textgroup.FontSize = 'Size10' 
        UnrefinedRank = newPlayer:GetRankInGroup(groupid)
        Person = newPlayer.Name

        if UnrefinedRank == 255 then 
                UnrefinedRank = "[HR] CEO" 

        end

        if UnrefinedRank == 10 then 
        UnrefinedRank = "[MR] Tier 4 Guard" 

        end

        if UnrefinedRank == 9 then 
        UnrefinedRank = "[MR] Tier 3 Guard" 

        end

        if UnrefinedRank == 8 then 
        UnrefinedRank = "[MR] Tier 2 Guard" 

        end

        if UnrefinedRank == 7 then 
        UnrefinedRank = "[MR] Tier 1 Guard" 

        end

        if UnrefinedRank == 6 then 
        UnrefinedRank = "[MR] Advanced Officer" 

        end

        if UnrefinedRank == 5 then 
        UnrefinedRank = "[LR] Officer" 

        end

        if UnrefinedRank == 4 then 
        UnrefinedRank = "[LR] Elite Security"

        end

        if UnrefinedRank == 3 then 
        UnrefinedRank = "[LR] Advanced Security" 

        end

        if UnrefinedRank == 2 then 
        UnrefinedRank = "[LR] Trained Security" 

        end

        if UnrefinedRank == 1 then
        UnrefinedRank = "[LR] In Training "

        end

        textgroup.Text = (' ' .. UnrefinedRank .. " ") 
        textgroup.Parent=guigroup

    end
end


function onPlayerEntered(newPlayer)
    newPlayer.Changed:connect(function (property) 
        if (property == "Character") then
            onPlayerRespawned(newPlayer)
        end
    end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
1
Not for sure since I can't test and I'm at school but try putting the connection line after the function is defined VariadicFunction 335 — 10y
0
Thanks! :) Can you just put a quick answer like abc and I will accept it. :) WelpNathan 307 — 10y
0
You called the first function before it even ran... raystriker6707 30 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

What zack785 said is correct. You attempted to call the function before you defined it.

groupid = 1123228
groupn = "LavaBlast Security Group" 

function onPlayerRespawned(newPlayer)
    wait(1)
    if newPlayer:IsInGroup(groupid) then
        guigroup=Instance.new("BillboardGui")
        guigroup.Parent=newPlayer.Character.Head
        guigroup.Adornee=newPlayer.Character.Head
        guigroup.Size=UDim2.new(4,0,2,0)
        guigroup.StudsOffset=Vector3.new(0,3,0)
        textgroup=Instance.new("TextLabel")
        textgroup.Size=UDim2.new(1,0,1,0)
        textgroup.BackgroundTransparency = 1
        textgroup.TextColor3 = Color3.new(255/255, 255/255, 255/255)
        textgroup.TextStrokeTransparency = 0
        textgroup.TextTransparency = 0
        textgroup.FontSize = 'Size10' 
        UnrefinedRank = newPlayer:GetRankInGroup(groupid)
        Person = newPlayer.Name

        if UnrefinedRank == 255 then 
                UnrefinedRank = "[HR] CEO" 

        end

        if UnrefinedRank == 10 then 
        UnrefinedRank = "[MR] Tier 4 Guard" 

        end

        if UnrefinedRank == 9 then 
        UnrefinedRank = "[MR] Tier 3 Guard" 

        end

        if UnrefinedRank == 8 then 
        UnrefinedRank = "[MR] Tier 2 Guard" 

        end

        if UnrefinedRank == 7 then 
        UnrefinedRank = "[MR] Tier 1 Guard" 

        end

        if UnrefinedRank == 6 then 
        UnrefinedRank = "[MR] Advanced Officer" 

        end

        if UnrefinedRank == 5 then 
        UnrefinedRank = "[LR] Officer" 

        end

        if UnrefinedRank == 4 then 
        UnrefinedRank = "[LR] Elite Security"

        end

        if UnrefinedRank == 3 then 
        UnrefinedRank = "[LR] Advanced Security" 

        end

        if UnrefinedRank == 2 then 
        UnrefinedRank = "[LR] Trained Security" 

        end

        if UnrefinedRank == 1 then
        UnrefinedRank = "[LR] In Training "

        end

        textgroup.Text = (' ' .. UnrefinedRank .. " ") 
        textgroup.Parent=guigroup

    end
end


-- ***You do not need the "onPlayerEntered" function to run the onPlayerRespawned function, it is redundant! It wouldn't work anyways, because you cannot use the .Changed event on a player.

game.Players.PlayerAdded:connect(onPlayerRespawned)

0
Ah. Thank chu! WelpNathan 307 — 10y
Ad

Answer this question