Hello, I have made the following script to give the player a tool based on their team color. Can you help me with why it isn't working for blue and red get the blue weapon? Here is the script:

function giveWeapon(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local alreadyHaveValue = hit.Parent:FindFirstChild("MyBool")
print(alreadyHaveValue)			
	if alreadyHaveValue == nil then
		print(hit)
		print(hit.Parent)				
		myValue = Instance.new("BoolValue")
		myValue.Name = "MyBool"
		myValue.Parent = hit.Parent
		myValue.Value = false
	elseif myValue == true then
		myValue:Delete()
	end
	if player ~= nil and myValue.Value == false then
		myValue.Value = true	        
		if player.TeamColor == BrickColor.new("Really blue") then
			print("I'm on team blue")	                
			local BlueLaserGun = game.Workspace.BlueLaserGun:Clone()
	        BlueLaserGun.Parent = game.StarterPack
	        elseif player.TeamColor == BrickColor.new("Really red") then
			print("I'm on team red")	                    
			local RedLaserGun = game.Workspace.RedLaserGun:Clone()
	        RedLaserGun.Parent = player.Backpack
		end

Thanks! Have a great day!

1 comment

0

Can you include the whole script?