Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this not work?

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago
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...
0
Thanks :) Anthony9960 210 — 8y
0
No problem. darkelementallord 686 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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

0
There is no problem inside the output :/ Anthony9960 210 — 8y
0
oh castro1688 0 — 8y

Answer this question