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

I got an Error for my Global Death script ? need help :)

Asked by 7 years ago
Edited 7 years ago

So i got a global death script for my minigame so when a player dies that he wont be in the Game anymore ( like registered ) so the game says "the blabla won" it did all work but now it says that :

Workspace.Globaldeath:5: bad argument #1 to 'Connect' (RBXScriptSignal expected, got function)

here is the script



game:GetService("Players").PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:waitForChild("Humanoid").Died.connect(function() local Update = {} for i,v in pairs(_G.gameplayers) do if v ~= player.Name then table.insert(Update,1,v) end end _G.gameplayers = Update end) end) end)

and how can i add that if a player dies he goes into the team "Medium stone grey" ? :) ty

0
What is gameplayers also why are you trying to iterate through a function... farrizbb 465 — 7y
0
I got it from the youtuber alvinblox.. Dont understand it ether. and gameplayers are the players who are in the minigame playing Paintertable 171 — 7y
0
Just edited to remove the extra ~ Shawnyg 4330 — 7y
0
I dont know what u mean. I just want to get rid off the Error and i need a fix code thanks Paintertable 171 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

I see your problem now! In line 3 of your posted code, you are supposed to use :Connect(), not .connect(). Also, :connect() is already deprecated, so you MUST get used to that (use :Connect() instead). Now, let me show you the fix:

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:waitForChild("Humanoid").Died:Connect(function() -- Use :Connect()
        local Update = {}
        for i,v in pairs(_G.gameplayers) do
                if v ~= player.Name then
                    table.insert(Update,1,v)
                end
        end     
            _G.gameplayers = Update
        end)
    end)
end)

If you have any questions, please leave them in the comments. Thanks!

0
By the way, you should try not to use _G because it is not as safe as you imagine. You can just keep it local in the Main Game Script, then use BindableEvents or BindableFunctions to communicate between the death script and the main game script. Use the Roblox Wiki for more info :) starlebVerse 685 — 7y
0
thank u very much :) gonna try it out later ^^ I love this site Paintertable 171 — 7y
Ad

Answer this question