I am creating a run script, and I am also trying to tween the camera zoom when it starts running. However, it isn’t working. Here is my code which is in StarterCharacterScripts. It’s giving me the error message Unable to cast dictionary to TweenInfo. I have tried changing the variable from the global one with no luck.
-- Object variables
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char.Humanoid
local camera = workspace.CurrentCamera
-- Services
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
-- Service Variables
local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
hum.WalkSpeed = 32
TS:Create(camera, TweenInfo, {FieldOfView = 100})
while UIS:IsKeyDown(Enum.KeyCode.LeftShift) do wait()
hum.WalkSpeed = 32
TS:Create(camera, TweenInfo, {FieldOfView = 100})
end
hum.WalkSpeed = 16
TS:Create(camera, TweenInfo, {FieldOfView = 70})
end
end)
-- Object variables
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char.Humanoid
local camera = workspace.CurrentCamera
-- Services
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
-- Service Variables
local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
hum.WalkSpeed = 32
TS:Create(camera, TweenInfo, {["FieldOfView"] = 100}):Play()
while UIS:IsKeyDown(Enum.KeyCode.LeftShift) do wait()
hum.WalkSpeed = 32
TS:Create(camera, TweenInfo, {["FieldOfView"] = 100}):Play
end
hum.WalkSpeed = 16
TS:Create(camera, TweenInfo, {["FieldOfView"] = 70}):Play()
end
end)
I tried the script under starter player scripts clicked shift and it didn’t make any errors
-- Object variables
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
-- Services
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
-- Service Variables
local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
hum.WalkSpeed = 32
TS:Create(camera, TweenInfo, {FieldOfView = 100}):Play()
while UIS:IsKeyDown(Enum.KeyCode.LeftShift) do wait()
hum.WalkSpeed = 32
TS:Create(camera, TweenInfo, {FieldOfView = 100}):Play()
end
hum.WalkSpeed = 16
TS:Create(camera, TweenInfo, {FieldOfView = 70}):Play()
end
end)