Hey developers! I have code that should destroy a weaponised cube while tweening, but almost none of my print messages actually print, and when they do, it just prints my body parts.
Here is the code
cube.Touched:Connect(function(hit)
print(hit)
if hit.Parent ~= nil and hit.Parent:FindFirstChild("Humanoid") then
local enemychar = hit.Parent
if enemychar.Name == char.Name or char:HasTag("NPC") or char:HasTag("Immortal") then return end
print("blud is immortal")
enemychar:WaitForChild("Humanoid").Health -= 10
else
if hit:HasTag("Passable") then
print(tostring(hit) .. " was passed thru by cube")
else
print(tostring(hit) .. " destroyed the cube")
cube:Destroy()
end
end
end)
Here is the video:
I really have NO IDEA what is going on here, and really need the functions to work to do something when it hits something.
that is happening because the cube is touching your character when it was first spawned
i donot think that is necessary because if smt is in workspace its parent will be workspace and touched event doesnot fire on removed/parts with nil parent
also make sure that your tags are the exact same name for example
the tag assigned to the npc should be NPC not Npc or npc (make sure that all your tags are correct)
You could try moving the cube with AssemblyLinearVelocity as suggested in the reply.
Another option is to still use tweening but repeatedly call the method workspace:GetPartBoundsInBox() or a more accurate but demanding method workspace:GetPartsInPart().