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

Can anyone help me with this regeneration button?

ok, here is what I have.

Inside workspace I have Child (Tycoons)

Inside Tycoons I have Child (BrightBlue)

Inside BrightBlue I have Child (Purchases)

Inside Purchases I have Child (BaseWall)

Inside BaseWall I have Child (Model)x100 or so

Inside each Model I have Child (Humanoid) with health at 1000

Now, I need a script that will make the Humanoid Health set at 1000 ( the blocks can be killed already)

The script will be attached to a button here is were it is located

Inside workspace I have Child (Tycoons)

Inside Tycoons I have Child (BrightBlue)

Inside BrightBlue I have Child (Purchases)

Inside Purchases I have Child (RegenerationBuilding)

Inside RegenerationBuilding I have Child (Buttons)

Inside Buttons I have Child (Regenerate Base Walls - $Price (this is the button))

Inside the Button I have Child (script) Named Regeneration

I know it was long but I hope you understand what I am asking.

Here is the script that I have


objects = {}
teamcolor = BrickColor.new(script.Parent.Name)
wait(1)

script.Parent.Essentials.Spawn.TeamColor = teamcolor
script.Parent.Essentials.Spawn.BrickColor = teamcolor


script.Parent.Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player ~= nil then
		if script.Parent.Owner.Value == player then
			if hit.Parent:FindFirstChild("Humanoid") then
				if hit.Parent.Humanoid.Health > 0 then
					local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
					if cashmoney ~= nil then 
						cashmoney.Value = cashmoney.Value + script.Parent.Cash.Value
						script.Parent.Cash.Value = 0
					end
				end
			end
		end
	end
end)

Workspace.Tycoons.BrightBlue.Purchases.BaseWall:WaitForChild("BaseWall")
for i,v in pairs(script.Parent.Parent.BaseWall:GetChildren()) do
	if v:FindFirstChild("Model") then        
           v.Humanoid.Health = 1000  
                v.Part.Transparency = 1 
                v.Part.CanCollide = false 
         
            end 
        end)
     



		











-- After 30 seconds, allow the model to be regenerated again
	wait(30)

This script is designed to make sure that the person clicking it is the owner of the base, alive, has the cash to buy it and a 30 sec timer.

that's all I can think of if you have any other ideas feel free to add....

Thanks for what ever help you can give

6 comments

0

ok, i just noticed that the transparency does not need to be there the script that i have that allows them to be killed takes care of that i just need the healthe rchanged to 1000

0

Is the MaxHealth of the Humanoids 1000?

0

yes

0

Sorry, im wrong.. i want the health to be set at 500, because i have an upgrad to give it the max health of 1000... but the max health is 1000 and normal is 500

0

so the script will need to be able to set it to 500 if not upgraded and 1000 if upgraded

0

i know a long way to make the script, nameing each model and pathing it all out seperate but i dont want to take that route.. i want a code that i can do it all in a short code

1 answer

Instead of v.Humanoid.Health = 1000 i would recommend v.Humanoid.Health = v.Humanoid.MaxHealth .

1 comment

0

and i dont get your problem other than that..

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