#Help setting up a model for damage

1 messages · Page 1 of 1 (latest)

obtuse pagoda
#

I have some models set up in order to help me test models taking damage properly for when I eventually try swapping the players to those models. However, I've only managed to get it to work correctly once and now I don't know how to do it again.

I've added screenshots of how the Rig and the Training Dummy are set up. The Dummy's Humanoid is correctly showing its HP and name, but doesn't take damage.

I'm also including a video of what's happening just in case, as well as the code that handles how hitboxes work below:
(This is a Script in ServerScriptServices)


local createHitbox = ReplicatedStorage:WaitForChild("CreateHitbox")
createHitbox.OnServerInvoke = function(plr, char, damage, size)
    local hitbox = Instance.new("Part")
    hitbox.Parent = workspace
    hitbox.CanCollide = false
    hitbox.Anchored = true
    hitbox.Size = size
    hitbox.BrickColor = BrickColor.new("Really red")
    hitbox.Transparency = 0.5

    hitbox.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)
    
    game.Debris:AddItem(hitbox, 0.2)
    
    local damageDealt = false
    hitbox.Touched:Connect(function(hit, processed)        
        if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") and not damageDealt then
            local dmgMult = tonumber(hit.Parent:GetAttribute("dmgMult"))
            
            damageDealt = true
            hit.Parent:FindFirstChild("Humanoid"):TakeDamage(damage * dmgMult)
        end
    end)
end```
#

Follow-Up

I guess as a TL;DR I just need help understanding everything that is needed for a character to be "ready" to be set as a player's character/model and just in general to take damage (for NPCs for example)

spark socket
#

i would suggest using raycast instead of part

#

and for the damage

#

FindFirstChild("Humanoid")

#

heres the issue

#

FindFirstChildOfClass("Humanoid")

#

this will help

#

@obtuse pagoda

tropic rain
obtuse pagoda
#

I know raycast is good for ranged weapons like guns n stuff but everywhere I look says parts tend to be fine for this

#

and I assume some other games that show hitboxes like idk Pillar Chase use something similar since those do just show you the big boxes used for damage

#

not to say I don't believe you, just saying why I used parts instead

obtuse pagoda
#

don't know if this will help, but I decided to add a line for print(hit) in the code and it'll print stuff just fine for the rigs, but it won't print anything when I try the same thing on the dummy

#

all the parts on the dummy have CanTouch set to true

tropic rain
#

use workspace:findpartsinpart instead of part.touched

obtuse pagoda
#

unless you mean something else

obtuse pagoda
#

ah it's in worldroot

#

myb

tropic rain
#

but ye the box one is better since you dont need a pointless part

obtuse pagoda
#

that sounds good

#

I guess quick question before I go

tropic rain
#

but also if you cant handle cframes then the part one is better for beginners

obtuse pagoda
#

so, again I know raycasting is good for ranged weapons but is it also good for melee, since that's most of what I'm coding atm

tropic rain
obtuse pagoda
#

I'm more than willing to take a few days to learn both, but just wanna ask to know where to start

winged wadiBOT
#

studio** You are now Level 2! **studio

obtuse pagoda
#

hi mee6

tropic rain
#

more accurately they're called spatial queries

obtuse pagoda
#

I see

#

I assume it works as like

tropic rain
#

i.e there's no difference between getpartboundsinradius and spherecast with 0 length

obtuse pagoda
#

a raycast but instead of a straight line it check in a box?

tropic rain
#

except maybe that the getpartboundsinradius gives all parts it touches, whereas the raycast/spherecast returns one result.

obtuse pagoda
tropic rain
obtuse pagoda
#

if it's not too much to ask where's a good starting point for learning this?

obtuse pagoda
tropic rain
#

there's other shapes too like blockcast and shapecast

tropic rain
#

and the docs

#

just read random docs pages

obtuse pagoda
#

fair yeah lol

tropic rain
#

and then put them into practice

obtuse pagoda
#

I moreso meant if there's a good video on it as well

tropic rain
#

that step is the most important, you can read the docs all you want but you still learn nothing if you don't try it out.

obtuse pagoda
#

but I can totally work w just the docs, thank you

tropic rain
#

same for tutorials. dont just blindly copy+paste.

#

take the tutorial's idea, and make it your own.

obtuse pagoda
#

I try to avoid it yeah

tropic rain
#

deliberately go out of your way to do things differently to the tutorial

obtuse pagoda
#

the dummy model I'm using is from the marketplace and it came with a script for damage numbers, but it didn't really work initially anyways and from what I read it was only to show each individual number

#

so while fixing it I also made it do like cumulative damage since I think it'd be good for a player to know how much total damage they've done to someone

#

alright well I'm gonna leave this post open until tomorrow, gonna try and read up on what you've mentioned and if I can get it to work I'll post it in here and close the post

#

and if I run into any issues I can't figure out I'll bring em up too