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

Values only updating one time when the player spawns?

Asked by 5 years ago

These values I noted do not change as the player's walkspeed change, but only when the player spawns. However in local they do change. Does anyone know how could I fix this? (This is not a local script)

local running = false;
local Connection = nil;
local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
volume = 1
playback = 1

function WhileRunning()
    if script.Parent.Materials.Value == "WoodenFloor" then
        script.Parent.WoodenFloor.Volume = volume
        script.Parent.WoodenFloor.PlaybackSpeed = playback
        script.Parent.WoodenFloor:Play()
    end 
end


function isRunning()
    if running and Humanoid.Parent.Torso.Velocity.magnitude > 1 then
        return true
    end
end


Humanoid.Jumping:connect(function()
    running = false;
end)


function doWhileRunning()
    Connection:disconnect();
    running = true;
    while (isRunning()) do
        volume = ((Humanoid.WalkSpeed)/8) --This
        playback = math.random(7,14)/10 --This
        print(volume .. " " .. playback)
        WhileRunning()
        wait(4.8/(Humanoid.WalkSpeed)) --This
    end
    running = false;
    Connection = Humanoid.Running:connect(doWhileRunning);
end

Connection = Humanoid.Running:connect(doWhileRunning)

Answer this question