So far i made it so that you can attack with a button1down function but I cant make it so the projectile that is spawned faces the same way as the player without changing the orientation.
player = game.Players.LocalPlayer repeat wait() until player.Character ~= nil local hum = player.Character.HumanoidRootPart local mouse = player:GetMouse() local tweenservice = game:GetService("TweenService") local function attack() local direction = hum.CFrame.lookVector * 60 local part = game.ReplicatedStorage.Water:Clone() part.Parent = workspace part.CanCollide = false part.Velocity = direction part.CFrame = CFrame.new(0,0,0) part.Orientation = Vector3.new(-90,0,0) part.Position = hum.Position + Vector3.new(0,-.5,0) local bf = Instance.new("BodyForce") bf.Force = Vector3.new(0, workspace.Gravity * part:GetMass() * 1, 0) bf.Parent = part wait(0.7) part:Destroy() end mouse.Button1Down:Connect(attack)
I did manage to change the orientation but when I do that the projectile doesn't shoot from the player. Any suggestions?
I think CFrame
Has a lookvector property
EXAMPLE
LocalScript
local Char = game.Players.LocalPlayer.Character local LookVector = Char.HumanoidRootPart.CFrame.LookVector -This is the lookvector [Projectile].CFrame = CFrame.new([Projectile].Position, Vector3.new(LookVector))
The wiki is down today soo :/ I'M NOT SURE
You can use this piece of code to face one part to another.
PartA.CFrame = CFrame.new(PartA.Position, PartB.Position)
The second argument of a CFrame
is were the CFrame
should face, the input is a Vector3
value.