Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My speed script wont increase speed?

Hey, im making a treadmill. TreadMill And this is the Code

local deb= false
local conveyer= script.Parent
local stats= game.ServerStorage.PlrFolder
local i= 0
local update= game.ReplicatedStorage.updateStats

script.Parent.Touched:Connect(function(hit)
if deb == false then deb=true
if hit.Parent:FindFirstChild("Humanoid") then
	local plr= game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		local pf= stats[plr.Name]
		local speed= pf.Speed
		
		do
		for _,v in pairs(script.Parent.Parent.active:GetChildren()) do
			v.BrickColor= BrickColor.new("Lime green")
		end
		end
		
		while (hit.Position - conveyer.Position).magnitude < 10 and hit.Parent.Humanoid.MoveDirection ~= Vector3.new(0,0,0) do
			i=i+1
				if i == 500 and speed < 40 then
				speed = speed+1	
				i=0
			end
			wait()
		end
		
		do
		for _,v in pairs(script.Parent.Parent.active:GetChildren()) do
			v.BrickColor= BrickColor.new("Bright blue")
		end
		end
		
		i=0
	end
end
deb=false
end
end)

But the walk speed does not increase:

if i == 500 and speed < 40 then

speed = speed+1

I tried placing the = and the + on other spots like this.

if i == 500 and speed < 40 then
speed = speed + 1

But as you already knew i did not work OOF So you guys know how to do this?

Treadmill: https://www.roblox.com/catalog/03133642024/redirect

Oh and the output says nothing

2 comments

0

I'm curious to know how you are storing the player names and why just not use "game.Players:GetPlayers()[plr.Name]"?

0

Becasue my friend helped me make this and i know a little of scripting

1 answer

I am not good at programming my self so i might be wrong, but i will guess you have to change how you define the speed.(I don`t understand the pairs and stuff so i can only fix first few lines sorry.)

script.Parent.Touched:Connect(function(hit)
    if deb == false then deb = true
    if hit.Parent:FindFirstChild("Humanoid") then
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    local speed = humanoid.WalkSpeed 
    --from here i do not know how to help sorry. 

So after defining what speed represents by finding from humanoid part, it should change the speed to whatever you want.

1 comment

0

if there is any mistake please tell me.

This discussion is preserved as it was. New answers, comments, and votes are closed.