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 am making a gun system and I have a module that returns the vector3 of where the barrel is pointing when I make a part that goes to that position every frame it shakes and flings all over the place but when I shoot the bullets go where they are supposed to
-
What is the issue? Include screenshots / videos if possible!
The end of the laser is where the part is (Where the beam is pointing)
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried making it a model and using PivotTo, Using CFrames, and that’s it
ALSO! after about 1 minute of the part just flinging it starts working properly and positioning properly
if you want to code I can send it.
Send me the code,codes are critical(must send the code to us when you post a report
I don’t understand exactly what you’re trying to achieve here. Can you describe it more clearer?
Laser Handler Function
function ManageLaser(Tool:Tool)
Tool = CurrentVM:WaitForChild(Tool.Name,5)
local Han = Tool:FindFirstChild("Handle")
local E = Instance.new("Attachment")
E.Parent = Han:FindFirstChild("LP")
print("DoingLaser")
if LaserLoop then
LaserLoop:Disconnect()
end
local Laserenabled = true
LaserPart = game.ReplicatedStorage.Laser:Clone()
LaserPart:PivotTo(workspace.CurrentCamera.CFrame)
mouse.KeyDown:Connect(function(Key)
if Key == "t" then
Laserenabled = not Laserenabled
end
end)
LaserLoop = game:GetService("RunService").RenderStepped:Connect(function()
if Laserenabled then
LaserPart.Parent = workspace.CurrentCamera
LaserPart.Laser.Beam.Attachment0 = E
local pos = BulletPositioner.Get(CurrentVM,CurrentVM:FindFirstChildWhichIsA("Tool"):FindFirstChild("Handle"):FindFirstChild("ShootPos"),{game.Players.LocalPlayer.Character,CurrentVM})
if pos then
LaserPart.Laser.Position = pos
end
else
LaserPart.Parent = game.ReplicatedStorage
end
end)
end
BulletPositioner Module
local module = {}
function module.Get(Character, Part)
local workspace = game:GetService("Workspace")
local partLookVector = Part.CFrame.LookVector
local startPosition = Part.Position
local maxDistance = 1000
local raycastParams = RaycastParams.new()
raycastParams.IgnoreWater = true
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {workspace.CurrentCamera,Part,game.Players.LocalPlayer.Character}
local result = workspace:Raycast(startPosition, partLookVector * maxDistance, raycastParams)
local endPosition
if result then
endPosition = result.Position
else
endPosition = startPosition + (partLookVector * maxDistance)
end
return endPosition
end
return module