Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Im getting a tool script error saying GetMouse is not a valid member of backpack?

So, Im making a script for a fireball, but through it im struggling. When I did this a long time ago it worked fine, but now its just breaking and making me angry. It says: GetMouse is not a valid member of BackPack.

Script 1:


local Tool = script.Parent
play = game.Players.LocalPlayer
mouse = play:GetMouse()
char = play.Character
hum = char.Humanoid

local en = true
Tool.Activated:connect(function()
	if not en then return end
	en = false
	Tool.RemoteEvent:FireServer(mouse.Hit)
	
	wait(0.5)
	en = true
end)

Script 2:

local Tool = script.Parent
play = script.Parent.Parent
local mouse = play:GetMouse()
char = play.Character
hum = char.Humanoid

local en = true

Tool.RemoteEvent.OnServerEvent:connect(function(play,mousehit)
   local a = hum:LoadAnimation(Tool.Melee)
	a:play()
	wait(1.4)
	
	wait(1.4)
	local fireball = Tool.Handle:clone()
	fireball.CFrame = Tool.Handle.CFrame
	local bv = Instance.new("BodyVelocity")	
	bv.MaxForce = Vector3.new(1e8,1e8,1e8)
	bv.Velocity = mousehit.lookVector * 50
	bv.Parent = fireball
	fireball.CanCollide = false
	fireball.Parent = game.Workspace
	
end)

1 comment

0

You cannot get the players mouse in a server script.

1 answer

GetMouse() is something from player, not backpack.

The error comes from script 2, line 2, as you don't have enough parents on line 2.

Use game.Players.LocalPlayer:GetMouse() and it should work fine.

8 comments

0

You're quick

0

Now its saying thats its not a valid member of itself

0

PlayerMouse*

0

are you requesting it from a script or a localscript? Script's cant acces GetMouse().

0

LocalScript, btw ur good at debugging

0

try game.Players.LocalPlayer:GetMouse() instead

0

I did for play, but its coming up with the PlayerMouse error though.

0

Continue this conversation in the site chat please, to many comments.

This discussion is preserved as it was. New answers, comments, and votes are closed.