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

How do i make a healing brick!?

Asked by 3 years ago

hi i was making a game where a part has to heal you but its no working please help

script.Parent.Touched:Connect (function(hit)
    if game.Players:GetPlayerFromCharacter (hit.Parent) then
        hit.Parent.Humanoid.Health = 10
    end
end)
0
How much health do you want it to heal you? XxThe_CoolestxX 0 — 3y

3 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago
-- Put this Heal Script in the part
function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then
        humanoid.Health = 100 --change this number if the player's maxhealth is higher
        script.Disabled = true
    end 
end

script.Parent.Touched:connect(onTouch)


-- Cooldown script
while true do
    if script.Parent.Script.Disabled == true then
        wait (5) --change this number to change the cooldown length in seconds to easily change to minutes change it to amount_of_minutes*60 for example 3 minutes would be (3*60)
        script.Parent.Script.Disabled = false
    end
    wait (0.1)
end


Ad
Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Try this:


script.Parent.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) then hit.Parent.Humanoid.Health = 100 end end)
Log in to vote
0
Answered by 3 years ago

if you want to make it add up, do this

script.Parent.Touched:Connect (function(hit)
    if game.Players:GetPlayerFromCharacter (hit.Parent) then
        hit.Parent.Humanoid.Health =  hit.Parent.Humanoid.Health + 7
    end
end)

Answer this question