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

How can I.....?

How can I make a script that gives the people on certain teams a certain weapon, like for example the red team would get a redish gun, the blue team would get a bluish gun, etc.

The script would also very much be appreciated.

2 answers

A script is not needed, all you have to do is to put the different weapons directly inside a team instead of the starterpack. This question has already been answered here, if you need more info.

1 comment

0

Thanks!

Ok first of all, never request a script, that's a rule of the website. By the way I am a good boy (lol) and I'll explain you how to do similar things:

IF YOU HAVE A CUSTOM LEADERBOARD:

If you have a custom leaderboard, then you are supposted to have a custom team value too as a String Value (this is important), let's name it "Team", now we need to check in what team is the player in.

First of all we need to declare some variables:

local players = game.Players:GetChildren() -- This will get EVERY player inside the server
local redGun = game.Lighting.RedishGun -- The Redish Gun, I assume that you have it in the lighting, if the name is wrong just change "RedishGun"to your redish gun real name, remember CaSe SeNsItIvE!
local blueGun = game.Lighting.BluishGun -- Same as the Redish one
local playerteam -- The player team, we need to set it from our next check function =)
local thePlayer -- The player, it will be defined in the next function =)

Those are all the variables we need, now we need to make a player check.

-- The function will be called as soon as the player join the game
game.Players.PlayerAdded:connect(function(player) 
	for _, player in pairs(players) do
		thePlayer = player -- The field is the same as minecraft's one (little EE).
		local team = player:FindFirstChild("Team") -- We search for the "Team" value
		if team then
			playerteam = team.Value
		end
	end
end)

Ok, now that we have the player team we need to give the guns! That's easy =)

function giveWeapons()
	 -- We wait for the StarterPack to be loaded, or we will get a nil error
	player:WaitForChild("StarterPack")
	-- If the team is "Red" then.... that's why you need to use StringValue!
	if playerteam == "Red" then
		redGun:Clone().Parent = player.StarterPack
	elseif playerteam == "Blue" then
		blueGun:Clone().Parent = player.StarterPack
	end
end

Now we need to call it in our player checker method! Add this line inside the team checker

if team then
	-- Call here the "giveWeapons" function
	giveWeapons() -- Add this line, not the condition (lol)
end

That's it!

WARNING: the code hasn't been tested, it may have some problems, PM me if you don't know how to resolve they =)

WAIIIIIITT!

IF YOU DON'T HAVE A CUSTOM LEADERBOARD:

Just put the models inside the teams in "Teams" service.

4 comments

0

I have the regular 'ROBLOX' leaderboard,and I put the guns into the teams but I am not spawning with them...

0

Are you spawning in any of the teams? Or just in a "Neutral" team? Make sure you used the roblox's spawn blocks (the colored one with a tribal circle in it as a decal)

0

Yeah, I am using those spawns, and yes I join a random team for example the blue team but I dont get that team's weapon.

0

Try using the custom leaderboard method, here's the link on how to do the custom leaderboard: http://wiki.roblox.com/index.php/Leaderboards

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