ok, I have a wall that has a humanoid in it with 500 start health per. block. and max health 1000 per. block.
the blocks will change their transparency when their health hits 0 (works)
I have a button that when clicked will add 500 health to the humanoid in each block if the humanoid health is less than 1000
the first thing that I want the button to do is check if the player is the tycoon owner, and then if he has enough money. the subtract the cash and add 500 health to each block in the wall.
the button is not working and I have no errors.
can someone look at this and see if I forgot something
thanks a lot!
script.Parent.ClickDetector.MouseClick:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
if script.Parent.Parent.Parent.Parent.Owner.Value == player then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney ~= nil then
if cashmoney.Value >= script.Parent.Parent.Price.Value then
cashmoney.Value = cashmoney.Value - script.Parent.Parent.Price.Value
for i,v in pairs(script.Parent.Parent.PurchasedObjects.BaseWall:GetChildren()) do
if not v:IsA("Script") then
if v.Humanoid.Health > 1000 then
v.Humanoid.Health = v.Humanoid.Health + 500
wait(2) -- Time to wait in between clicks
end
end
end
end
end
end
end
end)

2 comments
Sorry for bad grammar. I am on tablet.
Nvm just looked at the click detector functions... you are right.