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 10 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!

01script.Parent.ClickDetector.MouseClick:connect(function(hit)
02    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
03        if player ~= nil then
04            if script.Parent.Parent.Parent.Parent.Owner.Value == player then
05            local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
06                if cashmoney ~= nil then
07                    if cashmoney.Value >= script.Parent.Parent.Price.Value then
08                        cashmoney.Value = cashmoney.Value - script.Parent.Parent.Price.Value
09                        for i,v in pairs(script.Parent.Parent.PurchasedObjects.BaseWall:GetChildren()) do
10                            if not v:IsA("Script") then                                
11                                    if v.Humanoid.Health > 1000 then
12                                        v.Humanoid.Health = v.Humanoid.Health + 500
13                                        wait(2) -- Time to wait in between clicks
14                            end                        
15                        end
View all 21 lines...

1 answer

Log in to vote
0
Answered by
Scriptecx 124
10 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 — 10y
0
Nvm just looked at the click detector functions... you are right. Scriptecx 124 — 10y
Ad

Answer this question