I have a script that lets me move a model with the use of key binds, however, they move pretty abruptly.
The model is a spotlight, which if you have been to concerts, or seen them up close, moves in a smoother manner, sort of like a slow gradual increase of speed in the beginning, and a gradual slow down when it stops. (not sure how to explain it but think of the beginning and end of a sine wave)
local userInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local SpotlightHead = game.Workspace.Spotlight.Arm.Head
local UpdateCon
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
if input.KeyCode ~= Enum.KeyCode.KeypadEight then return end
if UpdateCon then
UpdateCon:Disconnect()
UpdateCon = nil
end
UpdateCon = RunService.Heartbeat:Connect(function(dt)
local newCFrame = SpotlightHead.PrimaryPart.CFrame * CFrame.Angles(0.05, 0, 0)
SpotlightHead:SetPrimaryPartCFrame(newCFrame)
end)
end)
userInputService.InputEnded:Connect(function(input, gameProcessedEvent)
if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
if input.KeyCode ~= Enum.KeyCode.KeypadEight then return end
if not UpdateCon then return end
UpdateCon:Disconnect()
UpdateCon = nil
end)
This is the script for the forward motion. (StarterPlayerScripts)
If you know a way to make this smoother, let me know!