I had tried to fix this for so long i dont know why the position of Main(part) that i weld not really valid
Can i anyone fix this ?
(No error detect in output)
Also When i set new part position equal with HumanoidRootPart (or any object in workspace) it work well
function RenderBullet(BStart,EndPos,Result)
local Beam = script.Bullet:Clone()
Beam.Parent = workspace.FX
Beam.CFrame = CFrame.new((BStart + EndPos) / 2 , EndPos)
Beam.Size = Vector3.new(.2,.2,(BStart - EndPos).Magnitude)
local Attach1 = Instance.new("Attachment",Beam)
Attach1.WorldCFrame = CFrame.new(BStart, EndPos)
local Attach2 = Instance.new("Attachment",Beam)
Attach2.WorldCFrame = CFrame.new(EndPos,BStart)
Beam.Beam.Attachment0 = Attach1
Beam.Beam.Attachment1 = Attach2
local Flash = script.Flash:Clone()
Flash.Parent = Attach1
Flash:Emit(3)
local Spotlight = script.SpotLight:Clone()
Spotlight.Parent = Attach1
TS:Create(Spotlight,TweenInfo.new(0.3),{Brightness = 0}):Play()
if Result then
if Result.Instance then
if Result.Instance.Parent:FindFirstChild("Humanoid") == nil then
local Hole = script.Hole:Clone()
Hole.CFrame = CFrame.new(Result.Position, Result.Position + Result.Normal)
Hole.Parent = workspace.FX
task.delay(1, function()
Hole:Destroy()
end)
end
end
end
end
UIS.InputBegan:Connect(function(Input , GPE)
if Input.UserInputType == Enum.UserInputType.MouseButton2 then
Aimming = true
elseif Input.UserInputType == Enum.UserInputType.MouseButton1 then
Shooting = true
CanShoot = false
local StartShoot = time()
local Shots = 0
repeat
if Shots < #RECOILS then
Shots+=1
end
GunSpring.Velocity += KICK
local Recoil = RECOIL
if time() - StartShoot > OOC then
Recoil += Vector3.new(0,(math.sin(10 * (time() - StartShoot))* 25),0)
elseif time() - StartShoot > REC then
Recoil += Vector3.new(0,(math.sin(5 * (time() - StartShoot))* 12),0)
end
local x = math.random(RECOILS[Shots][1]*10, RECOILS[Shots][2]*10)/10 - RECOILS[Shots][1]
local y = math.random(RECOILS[Shots][1]*10, RECOILS[Shots][2]*10)/10
local z = 0
Recoil += Vector3.new(x,y,z)
Recoil /= RECOILDAMPENER
RecoilSpring.Velocity+=Recoil
task.delay(RESETRECOIL,function()
RecoilSpring.Velocity-= Recoil
end)
-- TOO DOOOO!--
local EndPos
local Newpart = Instance.new("Part")
Newpart.Size = Vector3.new(.2,.2,.2)
Newpart.CanCollide = true
Newpart.CanTouch = false
Newpart.CanQuery = false
Newpart.Anchored = true
Newpart.Position = Gunmodel.Main.Position
Newpart.Parent = workspace.FX
local BStart = Newpart.Position
local Dir = (Mouse.Hit.Position - BStart).Unit
local Shoot = workspace:Raycast(BStart,Dir * RANGE,Params)
if not Shoot then
EndPos = BStart + Camera.CFrame.LookVector * RANGE
else
EndPos = Shoot.Position
end
if Shoot then
local RTable = {}
RTable.Instance = Shoot.Instance
RTable.Position = Shoot.Position
RTable.Distance = Shoot.Distance
RTable.Normal = Shoot.Normal
RTable.Origin = BStart
-- Remote:FireServer(RTable)
else
local RTable = {}
RTable.Position = EndPos
RTable.Distance = RANGE
RTable.Origin = BStart
--Remote:FireServer(RTable)
end
RenderBullet(BStart,EndPos,Shoot)
task.wait(CD)
until Shooting == false or AUTO == false
end
end)