I am having an issue where the raycasted bullet of my gun is coming from where it isn’t instead of where it is.
robloxapp-20250308-2330470.wmv (3.3 MB)
I believe this has something to do with a dynamic body movement script that i have in the playerscript, here’s that and the code where i determine where the bullet is coming from;
Dynamic body script:
My current script:
(this is in serverside script)
local tool = script.Parent
--Raycast
script.Parent.Shoot.OnServerEvent:Connect(function(player, mousePos)
local bulletReplicator = game.ReplicatedStorage.ReplicateBullets
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
tool.Handle["ShootSound"]:Play()
local startPos = tool.Handle.Barrel.Position
local velocity = 1650
local range = 800
local direction = CFrame.new(startPos,mousePos)
direction = direction.LookVector*velocity
local raycastresult = workspace:Raycast(startPos, (mousePos - startPos) * range, raycastParams)
bulletReplicator:FireAllClients(player.Character,startPos,direction,range)
local startTime = tick()
local lastPos = startPos
local rayFilter = RaycastParams.new()
rayFilter.FilterDescendantsInstances = {player.Character}
rayFilter.FilterType = Enum.RaycastFilterType.Exclude
Note: to be more specific, I am also using an animation while the gun is equipped, and the torso of that animation has no keyframes, in the animation editor it looks like the gun is facing the right and somehow shooting the middle, but combined with the camera script it looks like it’s facing straight, or mostly straight.