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
I have a few answers, try them and see which one fits your preference:
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)
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)
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)
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)