Remove Player's Character after using "X" Gear

Hey developers, I’m currently working on a “meme” game, and I need to add in gears to make the game feel like its the most random stuff in the world.

I’ve already added in some gears, but this one gear I’m having troubles with. I want to make it where if the gear has been used (activated), it would wait a few seconds, play an audio, then stop the studio and remove the players character.

Figuratively, you’d already know by the title, by I need to remove the player’s character from this specific gear. I already have a script written out but it just wouldn’t due to
“Line 5”.

Here is the code in question, ignore how messy it is…

local Tool = script.Parent;
enabled = true

script.Parent.Activated:connect(function(player)
	local Character = player.Character
	if not enabled  then
		return
	end

	enabled = false
	Tool.GripForward = Vector3.new(0,-.759,-.651)
	Tool.GripPos = Vector3.new(1.5,-.5,.3)
	Tool.GripRight = Vector3.new(1,0,0)
	Tool.GripUp = Vector3.new(0,.651,-.759)


	Tool.Handle.DrinkSound:Play()

	wait(3)

	local h = Tool.Parent:FindFirstChild("Humanoid")
	if (h ~= nil) then
		if (h.MaxHealth > h.Health + 5) then
			h.Health = h.Health + 5
		else	
			h.Health = h.MaxHealth
		end
	end

	Tool.GripForward = Vector3.new(0.954, 0, -0.3)
	Tool.GripPos = Vector3.new(0.03, -0.5, 0)
	Tool.GripRight = Vector3.new(0.3, 0, 0.954)
	Tool.GripUp = Vector3.new(0, 1, 0)

	wait(2)
	Tool.Handle.Scream:Play()
	wait(0.5)
	Tool.Handle.Scream:Stop()
	player.Character:WaitForChild("HumanoidRootPart"):Destroy()

	enabled = true
end)

script.Parent.Equipped:connect(function()
	Tool.Handle.OpenSound:play()
end)

enabled isn’t a local variable, also can we see the error?

Tool.Activated event doesnt have any parameters i think you miswrote it

To get the player from its character use this:
local player=game.Players:GetPlayerFromCharacter(Tool.Parent)
or
just
say:
local character=Tool.Parent

Maybe that’s what I’m missing… I’ll try this and I’ll get back to you.

it is because there is no player instance

1 Like

Yup, that was the thing I was missing. Thank you for helping!

No problem just a simple mistake on your end

1 Like