local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local ts = game:GetService("TweenService")
local WalkSpeed = 13
local SprintSpeed = 26
local cam = workspace.CurrentCamera
local sprintAnimation = Humanoid:LoadAnimation(game.StarterPlayer.StarterCharacterScripts.Run:WaitForChild("RunAnimation"))
local FOVin = ts:Create(cam, TweenInfo.new(.5), {FieldOfView = 100})
local FOVout = ts:Create(cam, TweenInfo.new(.5), {FieldOfView = 70})
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.ImageColor3 == Color3.new(0.392157, 0.392157, 0.392157) then
script.Parent.ImageColor3 = Color3.new(0.580392, 0.580392, 0.580392)
FOVin:Play()
Humanoid.WalkSpeed = SprintSpeed
sprintAnimation:Play()
else
script.Parent.ImageColor3 = Color3.new(0.392157, 0.392157, 0.392157)
FOVout:Play()
Humanoid.WalkSpeed = WalkSpeed
sprintAnimation:Stop()
end
end)
Okay, I have a working script that when the sprint button is active, it increases speed, and when it is inactive, it decreases speed to the base speed.
The problem is that the command “FOVin”, and “FOVout” do not play.
Although on my version for computers for sprint on shift, everything works the camera zooms out, but here it does not. There are no errors. Here if anything the computer version
local ts = game:GetService("TweenService")
local cas = game:GetService("ContextActionService")
local Humanoid = script.Parent:WaitForChild("Humanoid", 3)
local cam = workspace.CurrentCamera
local sprintAnimation = Humanoid:LoadAnimation(script:WaitForChild("RunAnimation"))
local RunSound = game.SoundService.Run
local WalkSound = game.SoundService.Walk
local isSprinting, ifSprintAnimPlay, RunSoundB, WalkSoundB = false, false, false, false
local FOVin = ts:Create(cam, TweenInfo.new(.5), {FieldOfView = 100})
local FOVout = ts:Create(cam, TweenInfo.new(.5), {FieldOfView = 70})
local function sprint(Type)
if Type == "Begin" then
isSprinting = true
Humanoid.WalkSpeed += 13
elseif Type == "Ended" then
isSprinting = false
Humanoid.WalkSpeed = 13
end
end
cas:BindAction("Sprint", function(_, inputState)
if inputState == Enum.UserInputState.Begin then
sprint("Begin")
else
sprint("Ended")
end
end, true, Enum.KeyCode.LeftShift)
--cas:SetTitle("Sprint", "Sprint")
--cas:SetPosition("Sprint", UDim2.new(1, -70, 0, 10))
game:GetService("RunService").RenderStepped:Connect(function()
if isSprinting and Humanoid.MoveDirection.Magnitude > 0 then
FOVin:Play()
if Humanoid:GetState() == Enum.HumanoidStateType.Running or Humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
if not ifSprintAnimPlay then
sprintAnimation:Play()
ifSprintAnimPlay = true
RunSound:Play()
RunSoundB = true
--WalkSound:Stop()
WalkSoundB = false
end
else
if ifSprintAnimPlay then
sprintAnimation:Stop()
ifSprintAnimPlay = false
RunSound:Stop()
RunSoundB = false
--WalkSound:Play()
WalkSoundB = true
end
end
else
FOVout:Play()
if ifSprintAnimPlay then
sprintAnimation:Stop()
ifSprintAnimPlay = false
RunSound:Stop()
RunSoundB = false
--WalkSound:Play()
WalkSoundB = true
end
end
end)