I am attempting to make a sprint button for mobile, but the button will not show up and I get this warning from the console.
20:39:27.137 - LastInputType change listener called with current type
Does the warning relate to the problem, what needs to be changed in the code below?
local mouse = game.Players.LocalPlayer:GetMouse()
local running = false
local char = script.Parent.Parent.Character
local RunningSpeed = char:WaitForChild("RunningSpeed")
local WalkingSpeed = char:WaitForChild("WalkingSpeed")
local RunVal = RunningSpeed.Value
local WalkVal = WalkingSpeed.Value
local UserInputService = game:GetService("UserInputService")
local isPressed = false
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Animate = char:WaitForChild('Animate')
local RunAnim = Animate.run:WaitForChild('RunAnim')
local Humanoid = Char:WaitForChild('Humanoid')
local LoadRunAnim = Humanoid:LoadAnimation(RunAnim)
local ContextAction = game:GetService("ContextActionService")
function Sprinting(name, inputState, inputObject)
if inputState ~= Enum.UserInputState.Begin then return end
if isPressed == false then
isPressed = true
Char.Humanoid.WalkSpeed = RunningSpeed.Value
game.Workspace.CurrentCamera.FieldOfView = 72
elseif isPressed == true then
isPressed = false
game.Workspace.CurrentCamera.FieldOfView = 70
Char.Humanoid.WalkSpeed = WalkingSpeed.Value
end
end
ContextAction:BindActionToInputTypes("Sprint",Sprinting,true)
ContextAction:SetTitle("Sprint", "Sprint")
