Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

@Abhay108 how?

2 comments

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.

0

bruh pledge is ltierally in a fricking function

This discussion is preserved as it was. New answers, comments, and votes are closed.