Speed Simulator Script Help

use a while loop with that code

while true do
wait(0.1)
local ServerScriptService = game:GetService(“ServerScriptService”)

if player.Character == nil then

player.CharacterAdded:Wait()

end

local startPosition = player.Character.Head.CFrame.Position

wait(1)

local Distance = (startPosition - player.Character.Head.CFrame.Position).Magnitute

if Distance > 1 then

Humanoid.Walkspeed = Humanoid.Walkspeed + 1

Speed = player.leaderstats.Speed

Speed.Value = 1

Speed.Value = Speed.Value + 1

Speed.Value = player.Character.Humanoid.Walkspeed

end
end

30char is nothing

just ignore it

2 Likes

Don’t mind it. Have you tested my code?

1 Like

Yes I’ve tested it and tried to edit it after it not working but it didn’t work. I wonder if it has something to do with the fact that speed might still not be connected to my script… It says in the script that
Speed.Value = 1
It doesn’t show up in the game when I play the game. It’s defaulted at 0.

1 Like

instead of while loops you can just use events

Humanoid.WalkToPart:Connect(function()
      -- code
end)
1 Like

Does this whole thing by any chance include a remote event? This is very confusing as my think is still not working.

no if you

could just get the humanoid’s parent in a script

So something like this
local Humanoid = game.Players.LocalPlayer.Humanoid?

nope like this

local character = script.Parent.Parent -- script.Parent is the humanoid and add another parent which is the character

So I have something like this
Humanoid.WalkToPart:connect(function()
local Character = script.Parent.Parent
wait(0.1)

local ServerScriptService = game:GetService(“ServerScriptService”)

if player.Character == nil then
player.CharacterAdded:Wait()
end

local startPosition = player.Character.Head.CFrame.Position
wait(1)
local Distance = (startPosition - player.Character.Head.CFrame.Position).Magnitute
if Distance > 1 then
Character.Walkspeed = Character.Walkspeed + 1
Speed = player.leaderstats.Speed
Speed.Value = 1
Speed.Value = Speed.Value + 1
Speed.Value = player.Character.Humanoid.Walkspeed
end)

Speed.Value = player.Character.Humanoid.Walkspeed
Assuming this doesn’t need to change.

add

a another

end

before the end)

Well uhh, the humanoid’s path looks like this:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")

leaderstats.Parent = player
under leaderstats.Name = “leaderstats”
I think