Simple code but need help

I made this script giving each player a wand(tool) but I don’t want the team ‘visitors’ to have a wand how do I make it that one team doesn’t get the wand?

The code to give the wand:
local Wand = wands[“Basic Wand”]:Clone()
Wand.Name = “Wand”
local weld = filler.Weld:Clone()
local client = filler.Client:Clone()
local md = filler.MouseDown:Clone()
local fixFlick = filler.FixFlick:Clone()
md.Parent = Wand
client.Parent = Wand
client.Disabled = false
weld.Parent = Wand
weld.Disabled = false
fixFlick.Parent = Wand
fixFlick.Disabled = false

	Wand.Parent = plr.Backpack

Hope you can help, Vosken.

i dont know from where u get plr, but if it dont use PlayerAdded then use:



for i, v in next, game.Players:GetPlayers() do
if v.Team == "visitors" then

else

local Wand = wands[“Basic Wand”]:Clone()
Wand.Name = “Wand”
local weld = filler.Weld:Clone()
local client = filler.Client:Clone()
local md = filler.MouseDown:Clone()
local fixFlick = filler.FixFlick:Clone()
md.Parent = Wand
client.Parent = Wand
client.Disabled = false
weld.Parent = Wand
weld.Disabled = false
fixFlick.Parent = Wand
fixFlick.Disabled = false

Wand.Parent = v.Backpack

  end
end

if plr.Team ~= game.Teams.visitors then
--give tool
end

Try this, hope it helps :+1:

1 Like

else if it uses PlayerAdded then:


game.Players.PlayerAdded:Connect(function()
if not plr.Team== "visitors" then
local Wand = wands[“Basic Wand”]:Clone()
Wand.Name = “Wand”
local weld = filler.Weld:Clone()
local client = filler.Client:Clone()
local md = filler.MouseDown:Clone()
local fixFlick = filler.FixFlick:Clone()
md.Parent = Wand
client.Parent = Wand
client.Disabled = false
weld.Parent = Wand
weld.Disabled = false
fixFlick.Parent = Wand
fixFlick.Disabled = false

Wand.Parent = v.Backpack
end
end

1 Like

He is getting the plr variable because he is using it in his script currently so it might not have to be used with PlayerAdded it might be from a remote or anything else.

1 Like

he should say his entire script, @vosken can u show me the entire script?

1 Like

Don’t worry he doesn’t have to we just have to go based on the variable he already has which is plr and we obviously know that equals the player in question.

Script is pretty big has 694 lines.

oh, but i thnk @MineDevs say good, u should give he the Solution

Just replace this line:

Wand.Parent = v.Backpack

With:

if plr.Team ~= game.Teams.visitors then
  Wand.Parent = v.Backpack
end

What we are doing is checking the players team property before we parent the wand making all teams except visitors receive it.

Yes but what stands the “v” for cause it gets underlined.

Nevermind, I changed te “v” to “plr” now it works thanks alot!

Thank you aswell for responding that fast :slight_smile:

I tought it worked but now nobody gets a wand xD.

you can only change to:


if not tostring(plr.Team) == "visitors" then
local Wand = wands[“Basic Wand”]:Clone()
Wand.Name = “Wand”
local weld = filler.Weld:Clone()
local client = filler.Client:Clone()
local md = filler.MouseDown:Clone()
local fixFlick = filler.FixFlick:Clone()
md.Parent = Wand
client.Parent = Wand
client.Disabled = false
weld.Parent = Wand
weld.Disabled = false
fixFlick.Parent = Wand
fixFlick.Disabled = false
Wand.Parent = plr.Backpack
end

oh and dont use else, use elseif and give a if statement

dm me with the entire code if it dont work becouse of the else

Nothing really worked here but thanks

You need to check if the player is in the team. So you need to get the player’s team color and see if its the Visitors team color. If it is then find the tool in their backpack and destroy it. Or you can just give precise teams the tool.