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

i am making a simulator game but the walk speeds do not match up....?

Asked by 4 years ago

i am making a simulator game and in it as you grow on size your walk speed gets slower so i tried this at first

game.Players.PlayerAdded:Connect(function(player)

        local humanoid = player.Humanoid

         humaoid.WalkSpeed = 16 * (Weight.Value / 250)

end)

but when you are at 0 weight(its my leaderstats) you do not move at all and even if you get to 16 to 17 weight your walk speed is not at all proportionate so then i tried this

game.Players.PlayerAdded:Connect(function(player)

        local humanoid = player.Humanoid

         humaoid.WalkSpeed = 16 * (Weight.Value + 1 / 250)

end)

but this made player go too fast now please tell me what i am doing wrong their are no errors in my script

2 answers

Log in to vote
1
Answered by 4 years ago

I have a few answers, try them and see which one fits your preference:

1. Nguyenlegiahung's answer (improved)

game:GetService("Players").PlayerAdded:Connect(function(plr) 
-- When a Player is Added
    plr.CharacterAdded:connect(function(char) 
-- When a player's character is added
        local hum = char:WaitForChild("Humanoid")
 -- Get the player's humanoid
        pcall(function() 
-- Basically a function that stops errors from stopping the whole script
            local loopc1 = coroutine.wrap(function() 
-- Basically a silent function
                while wait() do
 -- Forever loop
                    hum.WalkSpeed = 16 * (Weight.Value / 250) + 1 
-- The equation
                end
            end) loopc1() -- Run the silent function
        end)
    end)
end)

2. Making sure WalkSpeed isn't 0

game:GetService("Players").PlayerAdded:Connect(function(plr) 
-- When a Player is Added
    plr.CharacterAdded:connect(function(char) 
-- When a player's character is added
        local hum = char:WaitForChild("Humanoid")
 -- Get the player's humanoid
        pcall(function() 
-- Basically a function that stops errors from stopping the whole script
            local loopc1 = coroutine.wrap(function() 
-- Basically a silent function
                while wait() do
 -- Forever loop
                    hum.WalkSpeed = (16 * 1) * (Weight.Value / 250)
-- The equation
                end
            end) loopc1() -- Run the silent function
        end)
    end)
end)

3. Answer #1 and #2 combined

game:GetService("Players").PlayerAdded:Connect(function(plr) 
-- When a Player is Added
    plr.CharacterAdded:connect(function(char) 
-- When a player's character is added
        local hum = char:WaitForChild("Humanoid")
 -- Get the player's humanoid
        pcall(function() 
-- Basically a function that stops errors from stopping the whole script
            local loopc1 = coroutine.wrap(function() 
-- Basically a silent function
                while wait() do
 -- Forever loop
                    hum.WalkSpeed = ((16 * 1) * ((Weight.Value / 250) + 1))
-- The equation
                end
            end) loopc1() -- Run the silent function
        end)
    end)
end)
0
Nice response! haba_nero 386 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

I suggest you put +1 outside the bracket

game.Players.PlayerAdded:Connect(function(player)

        local humanoid = player.Humanoid

         humaoid.WalkSpeed = 16 * (Weight.Value / 250) +1 -- If it too fast then you can change it to +.5

end)

Answer this question