-
What do you want to achieve? I want to make a bullet that appears in front of the player (I have achieved this) and the bullet the face the direction the player is facing.
-
What is the issue? The bullet will appear in front of the player as planned, the only problem is that the bullet is turned opposite to the player (Horizontal rather than Verticle). Here’s a video of the issue.
-
What solutions have you tried so far? So far I’ve tried adding with multiple different Vector3 operations (I made sure to add it to the bullet) as well as multiply with CFrame angles.
This is in a server script in Server Script Services. The Positioning and rotating are on lines 49 to 52
local Time = 6
local e = 5
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local M6D = Instance.new("Motor6D", char.Torso)
M6D.Name = "ToolGrip"
end)
end)
local sound = game.ReplicatedStorage.Sounds.TommyGun
local sounddos = game.ReplicatedStorage.Sounds.Stab
game.ReplicatedStorage.JHamonReps.GunHit.OnServerEvent:Connect(function(player, humanoid)
local ssound = sounddos:Clone()
ssound.Parent = humanoid.Parent.Head
ssound:Play()
end)
game.ReplicatedStorage.JHamonReps.GunHit.OnServerEvent:Connect(function(player, humanoid)
if humanoid.Health >= 1 then
humanoid.Health = humanoid.Health - 1
elseif humanoid.Health < 1 then
humanoid.Health = 0
end
end)
game.ReplicatedStorage.JHamonReps.AttachGun.OnServerEvent:Connect(function(plr,location)
local csound = sound:Clone()
csound.Parent = plr.Character.Head
csound:Play()
local bt = game.ReplicatedStorage.JHGun:Clone()
bt.Parent = plr.Character
plr.Character.Torso.ToolGrip.Part0 = plr.Character.Torso
plr.Character.Torso.ToolGrip.Part1 = bt.BodyAttach
local pp = Instance.new("Part")
pp.Transparency = 1
pp.Parent = plr.Character
while Time > 0 do
if e < 1 then
pp:Destroy()
e = 5
pp = Instance.new("Part")
pp.Transparency = 1
pp.Parent = plr.Character
end
local be = game.ReplicatedStorage.Bullet:Clone()
be.Parent = plr.Character.Part
be.CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.LookVector*10
be.CFrame = be.CFrame + Vector3.fromAxis(Enum.Axis.X, 90)
e = e -1
wait(0.1)
Time = Time - 0.08
plr.Character.Part:WaitForChild("Bullet").Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid ~= plr.Character.Humanoid then
if plr.Character.Humanoid.Health > 0 then
if hit.Parent.Humanoid.Health >= 1 then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 1
elseif hit.Parent.Humanoid.Health < 1 then
hit.Parent.Humanoid.Health = 0
end
end
end
end)
end
pp:Destroy()
csound:Stop()
end)
game.ReplicatedStorage.JHamonReps.DetachGun.OnServerEvent:Connect(function(plr)
plr.Character.JHGun:Destroy()
plr.Character.Torso.ToolGrip.Part1 = nil
end)