I am trying to make a move where the character presses a button and they go to the mouse’s position smoothly.
I want the move to be like this
So far i’ve tried using tweenservice, body position, and body velocity, but I’m not getting what I want
This is the actual move:
-local firefist = game.ServerStorage:WaitForChild("FireFist")
local TweenService = game:GetService("TweenService")
local canTouch = false
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
game.ReplicatedStorage.FireFist.OnServerEvent:Connect(function(player, mouse)
local character = player.Character or player.CharacterAdded:wait()
local leftArm = character:FindFirstChild("Left Arm")
local newFireFist = firefist:Clone()
local torso = character:FindFirstChild("HumanoidRootPart")
local ray = Ray.new(torso.Position, CFrame.new(character.Head.CFrame.p, mouse.p).lookVector*3)
--local pos = player.Character:WaitForChild("Left Arm").Position + CFrame.new(player.Character.Head.Position,mouse.p).lookVector*2
newFireFist.CFrame = character:FindFirstChild("Right Arm").CFrame
--CFrame.new(character.Head.CFrame.p, mouse.p).lookVector * 3
newFireFist.Transparency = .5
--newFireFist.CanCollide = false
--
local pos = torso.CFrame * CFrame.new(0,0,-50)
local bodyPosition = Instance.new("BodyPosition", torso)
bodyPosition.Position = pos.p
--bodyPosition.D = 0
bodyPosition.P = 10000
--Debris:AddItem(bodyPosition, .6)
--[[local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(500000,500000,500000)
bodyVelocity.Velocity = torso.CFrame.lookVector*100
bodyVelocity.Parent = torso
]]
newFireFist.Parent = workspace
--newFireball.CFrame = CFrame.new(character.Head.CFrame.p, Mouse.p) + CFrame.new(character.Head.CFrame.p, Mouse.p). lookVector * 3
-- Tween Part
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local Objectives =
{
CFrame = (torso.CFrame * CFrame.new(character.Head.CFrame.p, mouse.p)+ CFrame.new(character.Head.CFrame.p, mouse.p). lookVector * 3)
--CFrame =
}
local makePartBiggerTween = TweenService:Create(torso, Info, Objectives)
wait(.1)
-- Damage
--local DamageParent = newFireFist
local DamageAmount = 15
newFireFist.CFrame = character:FindFirstChild("Right Arm").CFrame * CFrame.new(0,-1,0)
local weld = Instance.new("Weld")
weld.Part0 = character:FindFirstChild("Right Arm")
weld.Part1 = newFireFist
weld.C0 = character:FindFirstChild("Right Arm").CFrame:inverse()
weld.C1 = newFireFist.CFrame:inverse()
weld.Parent = newFireFist
--newFireFist.Anchored = false
newFireFist.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum and canTouch == false then
--newFireFist.CFrame = character:FindFirstChild("Right Arm").CFrame + Vector3.new(0,-1,0)
--if touchconn ~= nil then touchconn:Disconnect()end
--canTouch = true
if hit.Parent.Name ~= player.Name then
canTouch = true
print(hit.Parent)
hum.Health = hum.Health - DamageAmount
newFireFist:Destroy()
canTouch = false
newFireFist:Destroy()
end
end
end)
game.ReplicatedStorage.DestroyBall.OnServerEvent:Connect(function()
wait(1)
newFireFist:Destroy()
end)
wait(.1)
--makePartBiggerTween:Play()
end)
And this the local script for it
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local AnimationTrack = Animator:LoadAnimation(script.HoldingAnimation)
local AnimationTrack2 = Animator:LoadAnimation(script.FinsihedAnimation)
local Mouse = Player:GetMouse()
local Hold = false
AnimationTrack:AdjustSpeed(0)
AnimationTrack2:AdjustSpeed(0)
RunService.Heartbeat:Connect(function()
if Hold then
if not AnimationTrack.IsPlaying then
Character:WaitForChild("HumanoidRootPart").Anchored = true
AnimationTrack2:Stop()
AnimationTrack:Play()
end
else
if AnimationTrack.IsPlaying then
AnimationTrack:Stop()
AnimationTrack2:Play()
Character:WaitForChild("HumanoidRootPart").Anchored = false
end
end
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then
return
end
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.G then
Hold = true
game.ReplicatedStorage.FireFist:FireServer(Mouse.Hit)
end
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if gameProcessed then
return
end
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.G then
Hold = false
game.ReplicatedStorage.DestroyBall:FireServer()
--game.ReplicatedStorage.FireFist:FireServer(Mouse.Hit)
end
end
end)