Hello, I am having some problems with this script, and it is that I would like to make a part spawning on the player’s character but moving forward the mouse direction.
This is the script:
game.ReplicatedStorage:FindFirstChild("Combat System").Phoenix.OnServerEvent:Connect(function(Player, Player2, Dir)
print("got")
local p = bullet:Clone()
p.CFrame = CFrame.new(Player.Character.Sword.Main.Position)
p.Orientation = Vector3.new(0, Dir.Y, 90)
print(Dir)
local BV = Instance.new("BodyVelocity")
BV.Velocity = Dir*1
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Parent = p
print(Player.Character.HumanoidRootPart.CFrame.lookVector)
--local vector = Vector3.new(90,5,0)
--p.Orientation = vector * ((Vector3.new(1, Player.Character.HumanoidRootPart.CFrame.lookVector, 0)) + Vector3.new(0,5,0))
--print(p.Orientation)
p.Parent = DebrisFolder
game.Debris:AddItem(p,5)
local debounce = false
p.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name == Player.Name then return end
if not debounce then
debounce = true
local Hum = hit.Parent:FindFirstChild("Humanoid")
if Hum.Health > 0 then
Hum:TakeDamage(18)
else
end
end
end
end)
end)
It is a bit messed up, sorry.
Right now, it does not work normally. The part spawns good, but the direction does not look correctly, and the speed is messed up too.
´´´lua
game.ReplicatedStorage:FindFirstChild(“Combat System”).Phoenix:FireServer(Player, Mouse.Hit.p)
"Dir" stands for "Mouse.Hit.p"