Speed Every Second Error

So im trying to give the player speed every second, but when I do this there is no errors found in the output but it does not work, I stayed in the game for 10 minutes and I was still as slow as normal. Heres my script.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

-- Wait for character to load
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

-- Create speed value in leaderstats
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local speed = Instance.new("IntValue")
speed.Name = "Speed"
speed.Value = 0
speed.Parent = leaderstats

-- Create jump cooldown value
local jumpCooldown = Instance.new("IntValue")
jumpCooldown.Name = "JumpCooldown"
jumpCooldown.Value = 0
jumpCooldown.Parent = leaderstats

-- Create function to update speed
local function updateSpeed()
	speed.Value = speed.Value + 1
end

-- Connect to events for updating speed
humanoid.WalkSpeed = speed.Value
humanoid.Jumping:Connect(function()
	jumpCooldown.Value = tick() + 1
	speed.Value = speed.Value - 5
	humanoid.Health = humanoid.Health - 10
end)
RunService.RenderStepped:Connect(function()
	if jumpCooldown.Value == 0 or tick() > jumpCooldown.Value then
		updateSpeed()
	end
end)

You mean the Humanoid of the player doesnt increment the WalkSpeed?

You are updating the WalkSpeed of the Humanoid only once when the code run:

-- Create function to update speed
local function updateSpeed()
	speed.Value = speed.Value + 1
end

-- Connect to events for updating speed
humanoid.WalkSpeed = speed.Value -- HERE

I suppose you want to update it on each RunService step calling that updateSpeed() function like this:

-- Create function to update speed
local function updateSpeed()
	speed.Value = speed.Value + 1
	humanoid.WalkSpeed = speed.Value
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.