GetMouse() not working?

I am making a script for throwing a ball, for some reason, the script doesn’t work because of GetMouse() not working, here’s my code:

local tool = script.Parent
local char = tool.Parent

local plr = game:GetService("Players"):GetPlayerFromCharacter(char)

local mouse = plr:GetMouse()

what error are you getting in your output

The character might not be the parent right at the start of the script because the char needs to load in and get the tool first - try print(char)

Parent of the tool is either Backpack or players character when equipped, so if its not equipped your code wont work. GetMouse() only works in local scripts so you can get the player by simply doing player = game.Players.LocalPlayer.

Is this a serverscript? If yes, keep in mind that you can only get the player’s mouse from a localscript.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.