so when using mouse i can't find out how to get the position of the thing that the mouse is pointing at i try to do
mouse.Hit.position
but it says "this mouse is no longer active"
so when using mouse i can't find out how to get the position of the thing that the mouse is pointing at i try to do
mouse.Hit.position
but it says "this mouse is no longer active"
There are two solutions to this.
But first, we must address the problem at hand. You are getting this error because you are trying to use a mouse that is no longer active. This happens when you get the mouse as a parameter of the Equipped method of any Tool object.
The first solution would be to just get the mouse from the GetMouse method of the local player.
local players = game:GetSerivce("Players")
local localPlayer = players.LocalPlayer
local mouse = localPlayer:GetMouse()
The second solution would be to update the mouse every time the tool is equipped.
local mouse
tool.Equipped:Connect(function(givenMouse)
mouse = givenMouse
end)
i did that and it worked but there was a problem that came with changing it to a local script (see comment number 4)
nevermind i needed to do :WaitForChild("barrel") then i needed to do mouse.Hit.p then it worked!
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Are you getting the mouse as a parameter of a method of a tool, by any chance?
yes i am why??? ????
oop sorry for 8 question marks
so i put it in a local script and i did player:get mouse all of that stuff but i didn't use it before because when ever i use it, for some reason when i create a var called barrel it says that it is not in the tool i did script.parent.parent.barrel and it says it doesn't work it is so simple that i don't know how it is not working