Speed Simulator Script Help

Hey Guys. I made a topic earlier in which I needed help with making a speed simulator script. Everytime I move in any direction I want my leaderstat ‘Speed’ to go up by 1 everytime. I was lucky enough to have a in depth detailed description on how to make it. I’ve tried attempting to connect the pieces of his reply together but can’t quite figure out how. I came here for help. I’m a basic scripter wanting a better understanding on how to script.
Basic Leaderstat|554x231
This is the leaderstat I made with a value of Speed.


This is the script attempt at trying to make my speed go up by one everytime I move in any direction. I’m sorry if the script hurts your eyes because I’m really bad at scripting but that’s why I came here.
P.S
My leaderstat script is in the ServiceScriptService because I believe that’s where it goes.
And my AddSpeed Script (2nd photo.) is in the Players place.
If I got any of this wrong please help me out with where it should go and why.

I’ve already tried looking in the Roblox Developer Hub and found this useful piece of information.
https://developer.roblox.com/en-us/api-reference/property/Humanoid/WalkSpeed

I’ve looked all over YouTube for tutorials on this but yet can still not find one.

If you have any links that could be of help I would appreciate it a lot.

1 Like

Not sure if you did this or not but I dont see where Speed is defined by a variable

2 Likes

before setting speed you know that you cant replace anything with nil

please paste the code so we can have a look at it ASAP

1 Like

That would be where I’m really confused. As a basic scripter I’m trying to find out more stuff. Right now I don’t have the idea on how I can make a variable from a different script go into another script. Such as leaderstats. Speed is my leaderstat. The thing I want to do is bring the ‘Speed’ value from the leaderstat script into the AddSpeed script. I’m not quite sure how…

1 Like

Paste the code please so i can help you

2 Likes

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 =
Speed.Value = 1
Speed.Value = Speed.Value + 1
Speed.Value = player.Character.Humanoid.Walkspeed

end

1 Like

what is this

Speed = 

you have to reference it to something like this

Speed = player.Stats.Speed

then it will work

1 Like

Yeah sorry that’s another part I’m confused on. Trying to get the leaderstat of another script. AKA bring the value from the leaderstat script into the AddPoints Script.
So I suppose "Stats’ Refers to the leaderstat in a way?

1 Like

yes Change it to whatever your folder is called

1 Like

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.Folder.Speed

Speed.Value = 1

Speed.Value = Speed.Value + 1

Speed.Value = player.Character.Humanoid.Walkspeed

end

**What I have at the moment. My Folder for the leaderstat is just called “Folder”
Basic Leaderstat

1 Like

Didn’t someone explain this to you?

1 Like

that works

never mind this just 30char

1 Like

Yes but I can’t quite put the stuff together. I said I am a basic scripter. I’m not that great.

1 Like

it works i gurantee you that by looking at the scripts

1 Like

Oh looking at the script, just put this part of your script:

wait(1)

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

if Distance > 1 then

Humanoid.Walkspeed = Humanoid.Walkspeed + 1

Speed = player.Folder.Speed

Speed.Value = 1

Speed.Value = Speed.Value + 1

Speed.Value = player.Character.Humanoid.Walkspeed

end

inside a while loop:

while true do
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
1 Like

Good news and bad news for me. No errors what so ever. However the speed is not going up from the leaderstat…

1 Like

you called the folder name leaderstats not Folder

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
1 Like

This doesn’t work for me. I don’t know if we went of topic a bit or something but my goal was to make it add 1 speed every second… I think I’m really bad at this sorry guys…

1 Like

Have you tested my code?(30 charrrrr)

1 Like

What is ‘30 Char?’ Sorry but I’m new.

1 Like