I know that the player’s mouse in 3d space cframe wise is mouse.hit. But whenever I try to use mouse.hit, it doesnt work. Such as I made a tool that is supposed to fire stuff out of the player’s mouse, but it doesnt work. So I’m confused. Am I missing something?
This is the link to the other post i was talking about
If you are referring to the script in that post I don’t think you can do local Mouse.hit because it will only do that once and stay in that position, you have to fire mouse.hit to locate the mouse position ever Rendered step. I can make a code that moves an object to the player mouse if you want an example
I don’t think you need to do it every rendered step, you can just do hit = Mouse.hit before you call the remote event, therefore changing the mouse coordinates for the location of the mouse when you “fired”
This is code that will make a block at the player mouse relative to the position of the camera.
local Debris = game:GetService("Debris")
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local CanFire = true
function Fire()
if CanFire == true then
CanFire = false
delay(0.1,function()
CanFire = true
end)
local Object = Instance.new("Part",workspace)
Object.Anchored = true
Object.CFrame = Mouse.Hit --- this is what I mean by fire Mouse.Hit every time you fire
Object.Size = Vector3.new(1,1,1)
Object.Material = "Neon"
Debris:AddItem(Object,5)
end
end
Mouse.Button1Down:Connect(Fire)