You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want to transition the walking speed (10) to run speed (25) for example in criminality when you hold shift and when you let go the running speed transitions to the walking speed.
What is the issue? My script doesn’t work and there are no errors.
What solutions have you tried so far? I have looked around on the dev forum and tried different things but I can’t seem to find a solution.
Kinda embarrassing seeing how this is my second dev forum post today.
local uis = game:GetService("UserInputService")
local plr = game.Players.localPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local runservice = game:GetService("RunService")
walkspeed = 10
--speed up
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.LeftShift then
for i = 10, 25,1 do
runservice.Heartbeat:Wait()
walkspeed = i
end
end
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.LeftShift then
for i = 25, 10,1 do
runservice.Heartbeat:Wait()
walkspeed = i
end
end
end
end)
local uis = game:GetService("UserInputService")
local plr = game.Players.localPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local runservice = game:GetService("RunService")
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.LeftShift then
game.TweenService:Create(Humanoid, TweenInfo.new(1), {WalkSpeed = 25}):Play()
end
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.LeftShift then
game.TweenService:Create(Humanoid, TweenInfo.new(1), {WalkSpeed = 10}):Play()
end
end
end)
instead of using a for loop, why not just use tween service?
also walkspeed didn’t appear to ever be defined.
and you were doing a wait on something that was already loaded so i assume that would cause an infinite wait.