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

Why doesn't my gun get removed?

You know how when your gun is equipped or unequipped the gun is in different places right? That is my problem.

I tried two scripts to solve this. 1 for the gun in the character, and 1 for the gun being in the player's backpack.

The purpose of the script is to remove the gun when you stand up after you were sitting down from a certain seat.

Is there anything wrong with these scripts?

--When gun is equipped
while true do
	wait()
	if script.Parent.Parent:FindFirstChild("Humanoid").Sit == false then
		script.Parent:remove()
	end
end
--When gun is unequipped
while true do
	wait()
	if script.Parent.Parent.Parent:FindFirstChild("Character"):FindFirstChild("Humanoid").Sit == false then
		script.Parent:remove()
	end
end

I need an answer immediately.

2 comments

0

Replace :remove() with :Destroy().

0

Your problem is lines 4 of the first and second code; 'Humanoid' is not existant within the Player itself, and the Player's Character is not existant within the Player; The 'Character' is a property to specify the Player's Character; Not a Child within the Player itself. :P

1 answer

✓ Accepted answer

You misspelled Humanoid in the 4th line of When the gun is unequiped

1 comment

0

Umm the code block cut off part of the script and no I spelled it correctly.

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