:GetMouse() not working on server

I have a script inside a tool that detects it when somebody clicks on the tool, but it wont work because i cannot get the mouse for some reason, it says the player exists but when i do player:GetMouse() it returns nil

mousehahha = nil
player = nil
local t = script.Parent
script.Parent.Activated:Connect(function(e)
	if e then return end
	if t.Parent:IsA("Backpack") then return end
	if mousehahha == nil then
		if player == nil then
			player = game.Players:GetPlayerFromCharacter(t.Parent)
			print(player)
		end
		mousehahha = player:GetMouse()
		if mousehahha == nil then
			print("No mouse")
			print(mousehahha)
		end
	end
end)
1 Like

Um… I don’t think you can call :GetMouse() on the server… It has to be called from a LocalScript. If you don’t mind me asking, what were you trying to do with this script?

Mouse documentation: Player | Documentation - Roblox Creator Hub

spawn things on click at your mouse’s position, specifically explosions for this one and i was gonna make other ones like a ping and a revamped gun script

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