Why isn't my Touched event working

Hello,

I’m currently trying to create a Touched event for picking up an item. However, when a player touches the hitbox I’ve created, nothing happens. I’ve tried to use debug prints, which prove that the player is not triggering the event. I’m using another hitbox because I’m using tweens on the main dropped item.

Here’s my code:

hitbox.Touched:Connect(function(t)
		print("touched")
		if giving then print("already giving") return false end
		local potentialPlr = game:GetService("Players"):GetPlayerFromCharacter(t.Parent)
		
		if potentialPlr and potentialPlr.Name ~= plr.Name and module:IsPlayerAlive(potentialPlr) then
			print("let's go")
			giving = true
			if module:GiveWeapon(potentialPlr, "Gun") then
				print("drop")
				newDropped:Destroy()
			else
				print("can't give")
				giving = false
			end
		else
			print("can't give it to a dead person, or the same person who died beforehand")
			giving = false
		end
	end)

Any ideas? Let me know if you need more code. module:GiveWeapon() returns true or false

Thanks,
pos0.

Make sure the hitbox is a base part. :penguin:

If it detects hitbox usage, but if you want a weapon, I recommend you put it in “ReplicatedStorage” and clone it and automatically send it to the player’s backpack. Can I give you an example?

@Escape_Everything: It is a BasePart.
@ImNotServi: What do you mean? Yeah, give me an example. It isn’t even printing anything when I touch the Part.

But don’t we want the potentialPlr to be the Player?

1 Like

plr is the person dropping the gun, potentialPlr is the person picking it up.

what exactly does module:IsPlayerAlive do

cant you just check the health right there

It checks a BoolValue in ServerStorage, which is changed when the player dies, or respawns. I plan on changing this to module:IsPlayerInRound() soon, which checks if the player is alive and in the round.

So to confirm, when you step on the brick you get the "Touched" print?
When you step again you get the "Giving" print

If correct, you aren’t plr when you are testing, correct?

No, I don’t even get any prints at all.

Yes, I am not plr when testing.

Where about is this script located?

Server or Local

It’s a ModuleScript, and the DropGun() function is called when the player dies, and is sheriff.

This is a module script? Or is it not?

Oh, that’s inside of a function in the ModuleScript. It’s called when the player dies as Sheriff.

I’m not fully aware on if you can even run a .Touched event from a Module script… Have you tried just moving a script into the gun when dropped by the dead sheriff that requires the module?

1 Like

I haven’t tried that, but I’ll try it out. Give me a minute and I’ll tell you how it goes.

EDIT: Nevermind, I can’t do that. I don’t know how I would get the plr.
EDIT 2: Figured out how I would get the plr.

1 Like

Have you figured it out yet? Need help figuring something out?

Sorry, my internet has been acting up.