I’m working on a scene for my one of my games and I needed to use the touch event. Of course I quickly write it in a script and expect it to work. I test it, make the player go through an invisible wall that will detect when the player has touched it but nothing happens. Very confused but not surprised me goes to the forum and shamelessly copies a collision detection script. Overwrite the old script and well, nothing happened.
I have tried everything from making that wall not invisible and turn on collisions to crying until I die. Nothing worked.
That’s the code: I ended up using the raw unedited version because maybe I messed something up. And that didn’t work.
local part = script.Parent
local function onPartTouched(otherPart)
local partParent = otherPart.Parent
-- Look for a humanoid in the parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
-- Do something to the humanoid, like set its health to 0
humanoid.Health = 0
Now hear me out, the very confusing thing is that I tried the same setup in another game and it worked. Well the problem with that is I can’t move to another map, because other games are braching off of this one and moving every one of those to a new game is too much brain damage for me to handle, so yeah. Maybe I had plugins that messed up the game, so I uninstalled all of them. Issue proceeds to proceed.
So I’m stuck on this one. Do you have any thoughts on what might be the problem.
My only conclusion is that probably an external source is affecting the script. Check if anything is giving the player’s humanoid more health, the script being disabled, any other script disabling or destroying the part…
I know the issue now thanks to StormgamesYt7ip. I turned on collisions while testing, but that doesn’t register for some reason. Turning it on before testing has proven to be a solution. And of course thanks to everybody else for helping.