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

Can someone help me with this Health button?

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

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.

2 comments

0

Sorry for bad grammar. I am on tablet.

0

Nvm just looked at the click detector functions... you are right.

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