#how can i make point.value to walkspeed

5 messages · Page 1 of 1 (latest)

green marsh
#

local function onPlayerAdded(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local Speed = Instance.new("IntValue")
    Speed.Name = "Speed"
    Speed.Value = 0
    Speed.Parent = leaderstats
    
    local inventory = Instance.new("Folder")
    inventory.Name = "PetInventory"
    inventory.Parent = player

    local eqquippedPet = Instance.new("StringValue")
    eqquippedPet.Name = "EquippedPet"
    eqquippedPet.Parent = player
end

Players.PlayerAdded:Connect(onPlayerAdded)
while true do
    wait(5)
    local playerList = Players:GetPlayers()
    for currentPlayer = 1, #playerList  do
        local player = playerList[currentPlayer]
        local Speed = player.leaderstats.Speed
        Speed.Value = Speed.Value + 1
        player.Character.Humanoid.WalkSpeed += 1
    end
end
``` this is what i have right now, every 5 seconds i get +1 speed.value and +1 walkspeed but if i die i lose walkspeed but keep speed.value
green marsh
#

Anyone mind helping me?

quaint willow
#

you never reset the speed if they die

#
player.CharacterAdded:Connect(function()
   Character.Humanoid.WalkSpeed = Speed.Value
end)