Handle is not a valid member of Tool "Players.playerboygotswag2.Backpack.Pistal"

Hi, I’m making a game and I had errors, but I fixed them but this error I don’t get. on Roblox I had a gun, the code for it was working fine but I decided to add more part to the gun like the trigger so in order to do that I had to go to workspace take the handle out of the tool and take the part out of the handle to make it better then I put them back together brought is from the shop and now this error occur. BTW it’s a gun I made myself

local Gun = script. Parent
local Gun_Sound = Gun.Handle["Gun Shot"]
local empty_Sound = Gun.Handle.clip_empty
local reload_Sound = Gun.Handle.Reload


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ShotEvent")


Gun.Equipped:Connect(function(mouse)
	mouse.Button1Down:Connect(function()
		if Gun.Ammo.Value > 0 then
			remoteEvent:FireServer(Gun.Handle.Position, mouse.Hit.p)
			Gun_Sound:Play()
			Gun.Ammo.Value = Gun.Ammo.Value - 1
		else
			empty_Sound:Play()
			
		end
	end)
	
end)

please help cause it was fine before.

Do you mind showing us a picture of that tool[with its children/descendants - including the handle and parts].

line 2 is where the error is located at

1 Like

image

You have added a space.

Correction:

local Gun = script.Parent

Try this-

local Gun = script.Parent
local Gun_Sound = Gun:WaitForChild("Handle"):WaitForChild("Gun Shot")
local empty_Sound = Gun.Handle.clip_empty
local reload_Sound = Gun.Handle.Reload

And yeah, you accidentally made a space between script and parent. [sadly, it doesnt recognize it as legal operation]

1 Like

fixed it but still the same error

Then maybe the handle isnt loaded when the script ran.
Try what @Valkyrop said.

1 Like

thanks that helped now the code is working fine and I ran out of ammo. :slight_smile: