i made a running script and i use int value for walkspeed. it seems fine it works but when int value change the player walkspeed will be still the same as the origin int value and i cant find any solution how it will change the walkspeed when the int value change.
here is the script:
local player = game.Players.LocalPlayer.Character
local Pressed = game:GetService("UserInputService")
local debounce = 1
local Run = player.Humanoid:LoadAnimation(script.RunAnim)
local TweenService = game:GetService("TweenService")
local runvalue = player.RunSpeed.Value
local walkvalue = player.NormalSpeed.Value
Running = false
Pressed.InputBegan:Connect(function(key,speed)
if key.KeyCode == Enum.KeyCode.LeftControl and debounce == 1 and player.Stunned.Value == false then
player.Humanoid.WalkSpeed = runvalue
Running = true
debounce = 2
elseif key.KeyCode == Enum.KeyCode.LeftControl and debounce == 2 and player.Stunned.Value == false then
player.Humanoid.WalkSpeed = walkvalue
Running = false
debounce = 1
if Run.IsPlaying then
Run:Stop()
end
end
end)
player.Humanoid.Running:Connect(function(speed)
if speed >= 10 and Running == true and not Run.IsPlaying and player.Stunned.Value == false then
Run:Play()
elseif speed >= 10 and Running == false and Run.IsPlaying and player.Stunned.Value == false then
Run:Stop()
elseif speed < 10 and Run.IsPlaying and player.Stunned.Value == false then
Run:Stop()
end
end)
player.Humanoid.Changed:Connect(function()
if player.Humanoid.Jump and Run.IsPlaying then
Run:Stop()
end
end)
im new to scripting