Okay I know the title is a bit confusing but basically I have a flamethrower I am making that is animated when you click, but on the server it makes bullets which start from the position of the tip of the gun, since it's animated the gun moves a bit so when I shoot in game the bullets are a bit offset. How can I fix this?
In studio(What it should look like): https://gyazo.com/f118b151b2d0f59ede4b281678f89d27
In game: https://gyazo.com/32713f99a54ae5714bcba1d7b9bf485a
If u see it's not in the right position.
Server:
local plr = script.Parent.Parent.Parent
local char = plr.Character
local weld = Instance.new("ManualWeld", script.Parent.Backpack)
weld.Part0 = script.Parent.Backpack.PrimaryPart
weld.Part1 = char.UpperTorso
weld.C0 = CFrame.new(0,0.5,-0.8)
local HandleWeld = Instance.new("ManualWeld", script.Parent.Handle)
HandleWeld.Part0 = script.Parent.Handle
HandleWeld.Part1 = script.Parent.Gun
HandleWeld.C0 = CFrame.new(0,0,-1.7) * CFrame.fromEulerAnglesXYZ(1.5,-1.6,0)
local LWeld = Instance.new("ManualWeld", script.Parent.Backpack.L)
LWeld.Part0 = script.Parent.Backpack.L
LWeld.Part1 = script.Parent.Backpack.Union
LWeld.C0 = CFrame.new(0.7,-0.57,0)
local RWeld = Instance.new("ManualWeld", script.Parent.Backpack.R)
RWeld.Part0 = script.Parent.Backpack.R
RWeld.Part1 = script.Parent.Backpack.Union
RWeld.C0 = CFrame.new(-0.7,-0.57,0)
local SWeld = Instance.new("ManualWeld", script.Parent.Backpack.Straps)
SWeld.Part0 = script.Parent.Backpack.Straps
SWeld.Part1 = script.Parent.Backpack.Union
SWeld.C0 = CFrame.new(0,-0.65,0.6)
local TWeld = Instance.new("ManualWeld", script.Parent.Tip)
TWeld.Part0 = script.Parent.Tip
TWeld.Part1 = script.Parent.Gun
TWeld.C0 = CFrame.new(0.35,1.5,0)
local Tool = script.Parent
local active = false
math.randomseed(tick())
local debris = game:GetService("Debris")
Tool.Activated:Connect(function()
wait(0.2)
active = true
while wait() do
if active == true then
for i = 1,5 do
local new = Instance.new("Part")
new.Parent = workspace
debris:AddItem(new, 1)
local cM = math.random(1,2)
if cM == 1 then
new.BrickColor = BrickColor.new("Neon orange")
else
new.BrickColor = BrickColor.new("Bright yellow")
end
new.Transparency = 0.5
local Math = math.random(2,5)
new.Size = Vector3.new(Math/10,Math/10,Math/10)
local xm = math.random(-10,10)
local ym = math.random(-10,10)
local zm = math.random(-10,10)
local tip = script.Parent.Tip
new.CFrame = CFrame.new(Vector3.new(tip.Position.X + (xm/10), tip.Position.Y + (ym/10), tip.Position.Z + (zm/10)))
new.CanCollide = false
local bv = Instance.new("BodyVelocity", new)
bv.Velocity = char.HumanoidRootPart.CFrame.lookVector * 30
new.Touched:Connect(function(t)
if t.Parent:FindFirstChildOfClass("Humanoid") and t.Parent ~= char then
if t.Parent:FindFirstChildOfClass("Fire") == nil then
local f = Instance.new("Fire", t)
debris:AddItem(f, 5)
end
t.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(1)
end
end)
end
else
break
end
end
end)
Tool.Deactivated:Connect(function()
active = false
end)
Client:
wait(1)
local Tool = script.Parent
local Using = false
local Hum = game.Players.LocalPlayer.Character.Humanoid
Tool.Activated:Connect(function()
if Using == false then
local anim = Hum:LoadAnimation(script.Stance)
anim.Priority = Enum.AnimationPriority.Action
anim:Play()
Using = true
wait(0.18)
anim:AdjustSpeed(0)
end
end)
Tool.Deactivated:Connect(function()
Using = false
for _,v in pairs(Hum:GetPlayingAnimationTracks()) do
if v.Name == "Stance" then
v:Stop()
end
end
end)

2 comments
The parent argument to Instance.new is deprecated. Also why did you use so many Parents to get the player? And wait() should NOT be a condition.
If my answer satisfies your question, please accept it.