I’m trying to make an enemy like a goomba where if it touches you you die but if you jump on it’s head it dies. How would I sense what side of the part is being touched by the player and how would I make it damage the player or die?
All you really need to do is either make a map of the body parts or you can just detect which part is touched by getting the name. The proper way to do it is to create a map using a dictianary but I don’t think you really have to go that far. something like this would be fine
local function TouchedHead(otherPart) -- Code end local function TouchedBody(otherPart) -- Code end for _, Instance in pairs(Enemy:GetChildren()) do if Instance:IsA("BasePart") then -- checl if it is a part if Instance.Name == "Head" then Instance.Touched:Connect(TouchedHead) else -- you can add elseif statements here if you would like extra functionality Instance.Touched:Connect(TouchedBody) end end end
If you enemy has a lot of parts that make up your head (the character is a custom one) then you can simple make a dictionary and loop through it and connecting the revelant functions to the events.
Also remember to disconnect the events after you do not intend to use them for long periods of time.
All that did was unanchor it somehow but thanks.