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

Why does this not work?

I wrote a local script that is inside a startergui. This script is going to check if the player has a tool or any "towers" with a specific name and add them up. But when i add them up and got the sum it was 0 even though i got the tools and towers placed help?

function TowerCount()
local zombies = {}

local c = game.Workspace:GetChildren()

for index, child in pairs(c) do
if child.Name == "Turret-Archer "..game.Players.LocalPlayer.Name and child.Name == "Turret-Mage "..game.Players.LocalPlayer.Name then
table.insert(zombies, child)
end
end

return #zombies
end

function TowerInve()
local zombies = {}

local c = game.Players.LocalPlayer.Backpack:GetChildren()

for index, child in pairs(c) do
if child.Name == "Summon Archer" and child.Name == "Summon Mage" then
table.insert(zombies, child)
end
end

return #zombies
end

while wait() do
print(TowerCount() + TowerInve()) -- print out sum
end

2 answers

✓ Accepted answer
if child.Name == "Turret-Archer "..game.Players.LocalPlayer.Name and child.Name == "Turret-Mage "..game.Players.LocalPlayer.Name then
table.insert(zombies, child)
end

-- It can't be "Turret-Archer..." AND "Turret-Mage", I'd suggest converting it to OR instead...

2 comments

0

Thanks :)

0

No problem.

I don't see any problems here have you opened output?

2 comments

0

There is no problem inside the output :/

0

oh

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