You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to achieve the knife to look in the direction my character is looking
What is the issue? Include screenshots / videos if possible!
No issues I just don’t know how to make the rotation correct
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')
local ServerStorage = game:GetService('ServerStorage')
local TweenService = game:GetService('TweenService')
local Debris = game:GetService('Debris')
local Damage = 6
local function Detect(Character,plr)
local Connection
local knifeClone = script.Knife:Clone()
knifeClone.Parent = workspace
local Hitbox = knifeClone
knifeClone.CFrame = CFrame.Angles(0,Character.PrimaryPart.Rotation.Y - Character.PrimaryPart.Rotation.Y % 90,Character.PrimaryPart.Rotation.Z)
knifeClone.Position = Character.PrimaryPart.Position
local bv = Instance.new("BodyVelocity")
bv.Parent = knifeClone
bv.MaxForce = Vector3.new(80000,80000,80000)
bv.Velocity = Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 250
Connection = Hitbox.Touched:Connect(function(hitted)
if hitted.Parent and not hitted:IsDescendantOf(Character) and hitted.Parent:IsA("Model") then
if hitted.Parent:FindFirstChild("Humanoid") then
if hitted.Parent:FindFirstChild("Humanoid").Health > 0 then
knifeClone:Destroy()
local sound = script.Hit:Clone()
sound.Parent = hitted.Parent.Head
sound:Play()
Debris:AddItem(sound,1)
local Enemy = hitted.Parent
Enemy.Humanoid:TakeDamage(Damage)
Enemy.Humanoid:LoadAnimation(script.Hurt):Play()
Connection:Disconnect()
Hitbox:Destroy()
local B = Instance.new("BodyVelocity")
B.Parent = Enemy.HumanoidRootPart
B.MaxForce = Vector3.new(80000, 80000, 80000)
B.Velocity = Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 2
Debris:AddItem(B,0.25)
local object = Instance.new("ObjectValue")
object.Name = "Creator"
object.Value = plr
object.Parent = Enemy.PrimaryPart
if Enemy:FindFirstChild("DamageIndicatorGui") then
Enemy:FindFirstChild("DamageIndicatorGui").DamageIndicatorText.Damage.Value += Damage
else
local DamageIndicatorGui = game.ServerStorage.DamageIndicatorGui:Clone()
DamageIndicatorGui.Parent = Enemy
DamageIndicatorGui.DamageIndicatorText.Damage.Value = Damage
end
end
end
end
end)
end
ReplicatedStorage.Remotes.KnifeThrow.OnServerEvent:Connect(function(plr)
if plr.StandName.Value == "TheWorld" then
local character = plr.Character
if not character.PrimaryPart.Anchored == true and plr.Backpack.UsingMove.Value == false then
plr.Backpack.UsingMove.Value = true
for i, track in pairs(character.Humanoid.Animator:GetPlayingAnimationTracks()) do
if track then
track:Stop()
end
end
local anim = character.Humanoid.Animator:LoadAnimation(script.KnifeThrow)
anim:Play()
local sound = script.Throw:Clone()
sound.Parent = character.Head
sound:Play()
wait(1)
Detect(character,plr)
wait(1)
sound:Destroy()
plr.Backpack.UsingMove.Value = false
end
end
end)