Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would you detect the surface of a Player that was hit?

Asked by
Romul 21
5 years ago

I'm trying to find out if there is a way to detect what side of a brick you hit. I'm sure I'm going about this completely wrong and the code posted below will not work. The overall goal was to make it so when the back of a player was hit, it would deal damage. There isn't really a way to reference a hit's Surface though is there?

enabled = true

function onTouch(hit)
    if hit.Parent == nil then return end
    if enabled == true then
        if hit.Parent:FindFirstChild("Humanoid") and hit.Surface == "BackSurface" then
            enabled = false
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 10
        end
    end
end
1
id rather just make really thin parts to cover the sides The_Pr0fessor 595 — 5y
0
That'd be a way for sure, adding a thin, invisible part on the backside of a player that when it hit damages. Romul 21 — 5y
0
I read that article but it didn't do quite what I was hoping. I'm going to go with the method you suggested as a temporary work around. Thanks! Romul 21 — 5y
View all comments (2 more)
0
I'm assuming this is supposed to be a Touched event? What exactly are you using this for? Raycasting is a good method to look into. xPolarium 1388 — 5y
0
I'm sorry, I left the portion showing it was a Touched event. It is. I'm creating a combat system where a player is able to guard against attacks. Obviously though if an attack hits their back I want it to still damage or break the guard. Romul 21 — 5y

Answer this question