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

How can i make this script repeat after death?

Here is the script

local Player = game.Players.LocalPlayer --get the local player
 
local LVL = Player:WaitForChild("LevelingSystem"):WaitForChild("Lvl") --common reason as to why some LocalScripts don't work in studio, things haven't loaded in
 
LVL:GetPropertyChangedSignal("Value"):Connect(function()
 
    Player.Character.Humanoid.MaxHealth = LVL.Value * 100
wait(0.1)
    Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth

end)

1 comment

0

just put line 7,8,9 at the start and use syndicatehalos answer

2 answers

put in starterpack so it spawns with each person, if that is what you mean, otherwise i dont understand.

2 comments

1

yeah man u are right but the problem is it loads my hp only when i lvl up

0

just put line 7,8,9 at the start

This one is going to be really simple. We will simply connect the function you already made to the CharacterAdded event for the player.

local Player = game.Players.LocalPlayer --get the local player

local LVL = Player:WaitForChild("LevelingSystem"):WaitForChild("Lvl") --common reason as to why some LocalScripts don't work in studio, things haven't loaded in

function levelup()
    local humanoid = Player.Character:WaitForChild("Humanoid")
    humanoid.MaxHealth = LVL.Value * 100
    wait(0.1)
    humanoid.Health = Player.Character.Humanoid.MaxHealth
end

LVL:GetPropertyChangedSignal("Value"):Connect(levelup)
Player.CharacterAdded:Connect(levelup)

1 comment

0

Sorry cause i'm asking you this i'm still new to scripting.Should i add some kind of event to that local script or?

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