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

I made a script which edits person's health but it only works in studio what should i do?

Asked by
Echtic 128
6 years ago

Here is the script it makes max health equal to level * 100

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

local LVL = Player.LevelingSystem.Lvl --get the level



LVL.Changed:Connect(function() --when it is changed, update the health

    Player.Character.Humanoid.MaxHealth = LVL.Value * 100

    Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth --optional

end)

1 answer

Log in to vote
1
Answered by 6 years ago
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
    Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth 
end)

the GetPropertyChangedSignal() method is not really necessary in this case, but it "generates" an event for when the specified property is changed

0
Thanks mate, but it still works only in roblox studio Echtic 128 — 6y
0
where is the script and what type of script is it? creeperhunter76 554 — 6y
Ad

Answer this question