-
What do you want to achieve?
Kind of a pls donate animation
changes the field of view by a little bit
then tweens back to normal -
What is the issue? i get an error saying attempt to index number with ‘FieldOfView’
-
What solutions have you tried so far? wrapping it in spawn functions and pcall’s
-- Variables --
local CurrentSlot = nil
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local PlacementPosition = workspace:WaitForChild("Connect4"):WaitForChild("Positions")
local CurrentCamera = workspace.CurrentCamera
local HighestRow = 7
local Controls = require(Player.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
Controls:Disable()
-- Information --
local Slider = nil
local coincreate = game.ReplicatedStorage:WaitForChild("Templates"):WaitForChild("Coin"):Clone()
coincreate.Parent = workspace.Connect4
Slider = coincreate
-- Functions --
local function Changed()
spawn(function()
local old = 70
CurrentCamera.FieldOfView = CurrentCamera.FieldOfView - 5
wait(0.1)
TweenService:Create(CurrentCamera, TweenInfo.new(1, Enum.EasingStyle.Quint), {
FieldOfView = old
}):Play()
end)
end
local function ChangeSlot(new)
if new < HighestRow then
CurrentSlot = new
elseif new == HighestRow then
CurrentCamera = 1
end
if Slider then
local success, errormessage = pcall(function()
Changed()
end)
if not success then
warn(errormessage)
end
TweenService:Create(Slider, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {
CFrame = CFrame.new(PlacementPosition.Choosing[CurrentSlot].Position)
}):Play()
end
end
ChangeSlot(1)
-- Main Script --
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then
return
end
if input.KeyCode == Enum.KeyCode.D and UserInputService:GetFocusedTextBox() == nil then
ChangeSlot(CurrentSlot + 1)
end
if input.KeyCode == Enum.KeyCode.A and UserInputService:GetFocusedTextBox() == nil then
ChangeSlot(CurrentSlot - 1)
end
end)