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

How do I make a players WalkSpeed or Health's Value change according to the value of a leaderboard?

I've been trying to make a person's WalkSpeed and Health's Value increase by the Value of the leaderboard ( leader stats ) And this is the Script that I came up with

( Script for health that i made )

local Player = game.Players.LocalPlayer
local PlayersEnergy = Player:FindFirstChild('leaderstats'):FindFirstChild('Meme Energy')

while true do
      Player.Character.Humanoid.MaxHealth = PlayersEnergy.Value
      Player.Character.Humanoid.Health = PlayersEnergy.Value
wait(0)
end)

( Script for WalkSpeed that i made )

local Player = game.Players.LocalPlayer
local PlayersPower = Player:FindFirstChild('leaderstats'):FindFirstChild('Meme Power')

while true do
    Player.Character.Humanoid.WalkSpeed = PlayersPower.Value
wait(0)
end)

1 answer

✓ Accepted answer

Using while true do isn't the best way to do this, now assuming this is a local script you should use Changed instead.

local Player = game.Players.LocalPlayer
local PlayersEnergy = Player:WaitForChild('leaderstats'):FindFirstChild('Meme Energy')
local char = Player.Character or Player.CharaterAdded:Wait()

PlayersEnergy.Changed:Connect(function()
	char:WaitForChild('Humanoid').MaxHealth = PlayersEnergy.Value
end)

local Player = game.Players.LocalPlayer
local PlayersPower = Player:WaitForChild('leaderstats'):FindFirstChild('Meme Power')
local char = Player.Character or Player.CharacterAdded:Wait()

PlayersPower.Changed:Connect(function()
	char:WaitForChild('Humanoid').WalkSpeed = PlayersPower.Value
end)

This should work, if it doesn't check the output and tell me the error.

Good luck on your goal!

4 comments

0

@BlackOrange Where do I place the Local Script ?

0

Im increasing Meme Power's Value it doesnt seem to increase, I checked the Output no Output given about it.

0

My mistake, It's finally working! Thanks.

0

Np

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