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

Can someone help me with this Health button?

Asked by 9 years ago

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)

1 answer

Log in to vote
0
Answered by
Scriptecx 124
9 years ago

Try mousebutton1down instead of mouseclick.. I dont use click detectors that much so I dont kniw the functions for them but i bet its not mouseclick.

0
Sorry for bad grammar. I am on tablet. Scriptecx 124 — 9y
0
Nvm just looked at the click detector functions... you are right. Scriptecx 124 — 9y
Ad

Answer this question