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

?pledge is not a valid member of players. Help!

Asked by 5 years ago
Edited 5 years ago

pledge is not a valid member of Players

17:08:59.934 - Stack Begin
17:08:59.934 - Script 'Workspace.teamhandler', Line 6 - upvalue destroyAccessories
17:08:59.935 - Script 'Workspace.teamhandler', Line 30
17:08:59.935 - Stack End

Script:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

-- Check if the given object is an Accessory (such as a hat)
local function destroyAccessories(object, pledge)
    if game.Players.pledge.Team == "blue" then
        game.Players.pledge.Character.Shirt = 28578328
        game.Players.pledge.Character.Pants = 28578478
        local bat = game.Workspace.b.BluePaintballMask:Clone()
        bat.Parent = pledge
        local bg = game.Lighting["Paintball Gun (Blue)"]:Clone()
        bg.Parent = pledge
    else
        game.Players.pledge.Character.Shirt = 28578907
        game.Players.pledge.Character.Pants = 28578865
        local rat = game.Workspace.r.RedPaintballMask:Clone()
        rat.Parent = pledge
        local rg = game.Lighting["Paintball Gun (Red)"]:Clone()
        rg.Parent = pledge  
    end
end


local function onCharacterAdded(character)
    -- Wait a brief moment before removing accessories to avoid the
    -- "Something unexpectedly set ___ parent to NULL" warning
    RunService.Stepped:wait()
    -- Check for any existing accessories in the player's character
    for _, child in pairs(character:GetChildren()) do
        destroyAccessories(child, child)
    end
    -- Hats may be added to the character a moment after
    -- CharacterAdded fires, so we listen for those using ChildAdded
    character.ChildAdded:Connect(destroyAccessories)
end

local function onPlayerAdded(player)
    -- Listen for spawns
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

2 answers

Log in to vote
0
Answered by 5 years ago

@Abhay108 how?

0
You declared this line of code as players, local Players = game:GetService("Players") You have to define what pledge is, then it should work. Abhay108 0 — 5y
0
bruh pledge is ltierally in a fricking function iiDkOffical 109 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

You never declared pledge to be a member players.

0
how iiDkOffical 109 — 5y

Answer this question