What do you want to achieve?
Hi! so its my first time making topic here, and im trying to make a cannon that can
fling players to a specific location.
What is the issue?
I really dont know how to achieve this effect, i tried researching but theres not really much
results…
What solutions have you tried so far?
I tried using Tween Service to tween the player’s Humanoid Root Part to the location, but it just doesnt feel like being shot out of a cannon, and the camera seems to lag out.
Heres a prototype i tried using Tween Service:
–//Variables//—
–Objects
local cannonPart = script.Parent
local explosionAttachment = cannonPart.ExplosionAttachment
local selfPrompt = cannonPart.SelfPrompt
local cubePrompt = cannonPart.CubePrompt
local cubeSpawn = workspace.CubeSpawn
–Audio
local cannonSound = cannonPart.CannonSound
–Tween Service
local tweenService = game:GetService(“TweenService”)
local tweenInfo = TweenInfo.new(
0.3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
–Misc
local debounce = false
–//Functions//-
function tweenObject(object, tweenInfo, goal)
local tween = tweenService:Create(object, tweenInfo, goal)
tween:Play()
return tween
end
–//Main//–
selfPrompt.Triggered:Connect(function(player)
local character = player.Character
local explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0
character.PrimaryPart.Anchored = true
character:SetPrimaryPartCFrame(cannonPart.CFrame)
wait(1)
explosion.Position = explosionAttachment.WorldPosition
explosion.Parent = workspace
cannonSound:Play()
local tween = tweenObject(character.PrimaryPart, tweenInfo, {CFrame = cubeSpawn.SpawnPart.CFrame * CFrame.new(0, 5, 0)})
tween.Completed:Wait()
character.PrimaryPart.Anchored = false
end)