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

Assigning Weapons to a certain team?

I'm trying to make a script that whenever a player joins, it would loop the players and see if they are on Team1 or Team2. Then give the appropriate weapon to it. The script is a Module Script.

The problem is it does not assign it a Tool even though it has no errors, I've tried print debugging and it exactly locates to where it assigns the weapon.

All I need to know is why this is not working, not asking for anything other than that.

Thanks for viewing this!

function module:AssignTeamWeapons()
	local players = game.Players:GetPlayers()
	if #players == 1 then
		return nil
	end
	for i,v in pairs(players) do
		print("Looping through player"..v.Name)
		if v.Team == game.Teams.Team1 then
			local clone = game.ServerStorage.TeamWeapons.Pistol:Clone()
			clone.Parent = v:WaitForChild("Backpack")
			print("Gave Pistol to Survivor")
		elseif v.Team == game.Teams.Team2 then
			local clone = game.ServerStorage.TeamWeapons.ZombieTool:Clone()
			clone.Parent = v:WaitForChild("Backpack")
			print("Gave ZombieTool to Zombie")
		end
	end
end

1 answer

Do you ever callback that function with a server script?

Nvm found ur problem

"if #player == 1 then return nil end"

most likely ur testing this out solo

1 comment

0

I'm not sure what a "callback" is but I don't playtest solo I do a server test instead. Usually I server test with three players. All the print statements do print but the main problem is they are not giving the tool. Thanks for viewing.

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