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

How can i make this script repeat after death? [closed]

Asked by
Echtic 128
7 years ago

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)
0
just put line 7,8,9 at the start and use syndicatehalos answer abnotaddable 920 — 7y

Closed as Non-Descriptive by hiimgoodpack, lukeb50, Thundermaker300, and Goulstem

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

2 answers

Log in to vote
1
Answered by 7 years ago

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

1
yeah man u are right but the problem is it loads my hp only when i lvl up Echtic 128 — 7y
0
just put line 7,8,9 at the start abnotaddable 920 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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)
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? Echtic 128 — 7y