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
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?
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.
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?