CONTEXT: after the output from player the script will lunch a object from the player, move toward the player facing if amount of time the part will be deleted.
so you want to shoot an object where the player is looking?
you can calculate the direction for the projectile by using (humanoid.TargetPoint - humanoidrootpart.position).Unit * power i think or use the humanoidrootPart.CFrame.LookVector
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, hit)
if cooldowns[plr] or not hit then return end
cooldowns[plr] = true
--------XYZ
local x = 6.586
local y = plr.Character.PrimaryPart.Orientation.Y
local chain = game.ServerStorage.Part:Clone()
chain.CFrame = CFrame.fromEulerAnglesXYZ(x,y,0)
chain.Size = Vector3.new(1.918, 10.156, 38.507)
chain.Anchored = true chain.CanCollide = false
chain.Parent = workspace
chain.Position = plr.Character.PrimaryPart.Position
local ts = game:GetService("TweenService")
local move = ts:Create(chain, TweenInfo.new(1.1), {Position = plr.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector})
move:Play()
cooldowns[plr] = false
end)
The part move toward the (vector = 0,0,0) and not toward the player is facing to.
The look vector is a unit vector, which means it’s on a scale of [-1, 1] for each coordinate with a guaranteed magnitude of 1 (or it’ll be a nan value but that doesn’t apply in our case)
What you would want to do is translate the current CFrame by the LookVector (with a multiplied magnitude for how far you want it to go)
local Distance = 10 -- 10 Studs of max distance
local TargetPart = workspace.Part -- Make this your projectile
local RootPart = game.Players.LocalPlayer.Character.HumanoidRootPart -- Caster character's root part
local EndCFrame = RootPart.CFrame * CFrame.new(RootPart.CFrame.LookVector*Distance) -- "Adds" the new direction to the current CFrame
TargetPart.CFrame = EndCFrame -- Sets the part's cframe, change this to a tween at your will
(note: if you reply, I won’t be able to respond for a while)