Glad to see you’re back. Anyways, it seems to not play the sound for some reason? Also how would i make the player move toward the target part at the same speed no matter the distance, and how would i make it so that the player can’t hit the part again after having jumped off it until he hits another part or lands?
--|Targeting
local OnAir2 = false
local function Targeting()
print("a")
if Settings:GetAttribute("Moveset") == true and Settings:GetAttribute("Targeting") == false then
print("c")
local Params = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
--------------------------------------
local TargetPart = nil
local Connection
--------------------------------------
Connection = UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Space then
if TargetPart then
Connection:Disconnect()
--------------------------------------
Settings:SetAttribute("Targeting", true)
--------------------------------------
Root.Anchored = true
--------------------------------------
Root.CFrame = CFrame.new(Root.Position, TargetPart.Position)
--------------------------------------
Anims.Target:Play(0, 30)
--------------------------------------
local Sound0 = Sounds.Player.TargetingSound:Clone()
Sound0.Parent = Root
Sound0:Play()
--------------------------------------
Debris:AddItem(Sound0, 1.25)
--------------------------------------
local Start = Root.CFrame
for i = 0.1, 1, 0.1 do
Root.CFrame = Start:Lerp(TargetPart.CFrame, i)
task.wait(0)
end
--------------------------------------
Settings:SetAttribute("Targeting", false)
--------------------------------------
Root.Anchored = false
--------------------------------------
Anims.Target:Stop()
--------------------------------------
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
--------------------------------------
spawn(function()
Glow:Create(Color3.fromRGB(0, 255, 255), "All", 1)
end)
--------------------------------------
local Sound1 = Sounds.Player.TargetHitSound:Clone()
Sound1.Parent = Root
Sound1:Play()
--------------------------------------
Debris:AddItem(Sound1, 2.75)
end
end
end)
--------------------------------------
repeat
local Parts = workspace:GetPartBoundsInRadius(Root.Position, 30, Params)
print("a")
--------------------------------------
local MaxDistance = 9999
local ClosestPart = nil
for _, Part : Part in pairs(Parts) do
local Magnitude = (Part.Position - Root.Position).Magnitude
if Part:HasTag("Target") and Magnitude < MaxDistance then
MaxDistance = Magnitude
ClosestPart = Part
end
end
--------------------------------------
if ClosestPart then
--[[ if TargetPart and not TargetPart.Target.Enabled then
local Sound = Sounds.Player.TargetSound:Clone()
Sound.Parent = TargetPart
Sound:Play()
--------------------------------------
Debris:AddItem(Sound, 0.5)
--------------------------------------
TargetPart.Target.Enabled = true
end]]
--------------------------------------
ClosestPart.Target.Enabled = true
end
--------------------------------------
if TargetPart and TargetPart ~= ClosestPart then
TargetPart.Target.Enabled = false
end
--------------------------------------
TargetPart = ClosestPart
--------------------------------------
task.wait()
until Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping
if TargetPart then
TargetPart.Target.Enabled = false
end
--------------------------------------
Connection:Disconnect()
end
end