mouse.Hit IS a CFrame. We just take the position out using mouse.Hit.Position.
meaning the position is the same as the cframe itself.
mouse.Hit IS a CFrame. We just take the position out using mouse.Hit.Position.
meaning the position is the same as the cframe itself.
Ah right, that is probably causing your issue in CFrame.new(MuzzlePos, MousePos)
if MousePos is already a CFrame it will errror out. I do not get the problem here as I have been able to replicate the script with no issues.
i use mouse.hit.position, not mouse.hit
Can you clarify what the exact issue is? It seems to be working fine.
it’s in the title
I’VE TYPED T.H.I.R.T.Y. CHARACTERS BERFORE
And I have been saying that it works fine for me, it does not fall. I copied and replicated your script like this:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, pos)
local bullet = Instance.new("Part")
bullet.Name = "Bullet"
bullet.CanCollide = false
bullet.Anchored = false
bullet.Massless = true
bullet.Size = Vector3.new(0.1, 0.1, 1) --Vector3.new(0.02, 0.02, 0.045)
bullet.CFrame = pos
bullet.Material = Enum.Material.Neon
bullet.BrickColor = BrickColor.new("Cool yellow")
bullet.Parent = workspace
print("Step 1 done.")
bullet:SetNetworkOwner(nil)
print("Step 2 done.")
--bullet.AssemblyLinearVelocity = (bullet.CFrame.LookVector * 100)
local bodyVelo = Instance.new("BodyVelocity")
bodyVelo.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelo.Velocity = (-bullet.CFrame.LookVector * 100)
bodyVelo.Parent = bullet
local bodyForce = Instance.new("BodyForce")
bodyForce.Force = Vector3.new(0, workspace.Gravity * 1)
end)
print("Success.")
Something from the rest of the script… maybe?
the event is true, but there’s no point of setting multiplied to 1 since 1 is the original
Right, but that is not the problem you are facing. Is it fixed now?
nope. I 100% THINK IT’S THE MOUSE POSITION
Can you please add debugging with print() statements so you can identify the problem.
It’s literally there. In the script
I meant the variables, printing out Step1 and Step2 doesnt change anything if the CFrame is invalid / wrong, either way you should print out the mousepos to see if you are getting it how you want.
i already did the printing ads ads ads
Then what seems to be the problem? Just send the mouse hit cframe to the server and apply lookVector to it
I fixed it by replacing the mouse.Hit.Position with this
function getWorldMousePosition()
local mousePosition = UserInputService:GetMouseLocation()
local screenToWorldRay = Camera:ViewportPointToRay(mousePosition.X, mousePosition.Y, 1000)
local dirVector = screenToWorldRay.Direction * 1000
local rayResult = workspace:Raycast(screenToWorldRay.Origin, dirVector, RaycastParams.new())
if rayResult then
return rayResult.Position
else
return screenToWorldRay.Origin + dirVector
end
end
It was the mouse position afterall. Told ya
Where I found the script: