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

My speed script wont increase speed?

Asked by 5 years ago

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

0
I'm curious to know how you are storing the player names and why just not use "game.Players:GetPlayers()[plr.Name]"? DeceptiveCaster 3761 — 5y
0
Becasue my friend helped me make this and i know a little of scripting jorickbouw 0 — 5y

1 answer

Log in to vote
0
Answered by
Yuuwa0519 197
5 years ago

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.

0
if there is any mistake please tell me. Yuuwa0519 197 — 5y
Ad

Answer this question