#how to make a damage brick work?

1 messages · Page 1 of 1 (latest)

wintry prawn
#

so i made this damage brick for a troll tower game but now i dont know how to make the damage so i tried my best and put a script in the damage brick part and here is the screenshot

#

it didnt work if you could guess

tranquil vine
#

Your parameter name is PartB

#

But on line 4 you say:

local humanoid = ***hit***.Parent: FindFirstChild("Humanoid")

#

Change hit to your parameter name

#

Or change the parameter name to "hit"

wintry prawn
#

ah thanks

#

is there also a way i can make the forcefield time a bit shorter?

tranquil vine
#

Forcefield??

wintry prawn
#

like when you spawn

#

it has like a forcefield bubble

tranquil vine
#

Nope I don't know

#

Never dealt with forcefields before

wintry prawn
#

ah ok but the script still doesnt work is there a better script?

#

must i do local script in starter player or smth?

tranquil vine
#

Huh

#

Odd

#

Try humanoid:TakeDamage(10) instead

rose sleet
#

try replacing findfirstchild with waitforchild

wintry prawn
#

both dont work

grim galleonBOT
#

studio** You are now Level 1! **studio

rose sleet
#

ye u used it wrong

wintry prawn
#

ah sorry

#

wait so how do i fix it? cuz i typed it right now and still wont work

rose sleet
#

send it then

wintry prawn
#

local damageBrick = script.Parent

damageBrick.Touched:Connect(function(hit)
local humanoid = hit.Parent:WaitForChild("Humanoid")
if humanoid then
part.CanTouch = false
task.wait(.5)
humanoid:TakeDamage(10)
task.wait(1)
part.CanTouch = true
end
end)

here is the full code

tranquil vine
#

On line 1 try local damageBrick = script.Parent:Wait()

rose sleet
#

try checking if the hit is a accessory then get the player with findfirstancestor then do .humanoid

#
if hit:IsA("Accessory") then
   humanoid = hit:FindFirstAncestorWhichIsA("Player").Humanoid
end
wintry prawn
#

ok can you maybe recode if you can so i can understand?

rose sleet
#

Nah

#

My keyboard isnt good right now

wintry prawn
#

ah ok

#

how do i check if hit is an accessory

short quarry
wintry prawn
#

the damage brick wont take damage at all

short quarry
# wintry prawn the damage brick wont take damage at all
local damageBrick = script.Parent

damageBrick.Touched:Connect(function(hit)
    local humanoid = hit.Parent:WaitForChild("Humanoid")
    if humanoid then
        damageBrick.CanTouch = false
        task.wait(.5)
        humanoid:TakeDamage(10)
        task.wait(1)
        damageBrick.CanTouch = true
    end
end)
wintry prawn
#

wait it just took half health

#

must i switch it to humanoid.health -= 10?

short quarry
rose sleet
#

Whichever works

short quarry
#

it doesnt matter which if takedamage or humanoid.health

wintry prawn
#

ah ok but how do i make it so it has to wait to damage me again if i stand on it for too long

grim galleonBOT
#

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

rose sleet
#

thats called a debounce

wintry prawn
#

so where do i add a debounce?

#

well where

rose sleet
#

before the touched event

short quarry
# wintry prawn so where do i add a debounce?
local damageBrick = script.Parent
local debounce = true

damageBrick.Touched:Connect(function(hit)
    local humanoid = hit.Parent:WaitForChild("Humanoid")
    if humanoid and debounce then
        debounce = false
        humanoid:TakeDamage(10)
        task.wait(1)
        debounce = true
    end
end)
rose sleet
#

yeah

wintry prawn
#

thanks so much

rose sleet
#

is it working?

wintry prawn
#

yes

#

now i just need to make the spawn forcefield bubble shorter time limit like when you first spawn

rose sleet
#

when ur character spawns clone it and set its hrp to the new ones hrp

wintry prawn
#

ah ok

rose sleet
#

maybe it will work

wintry prawn
#

i will try

short quarry
#

there is a property called duration that changes the forcefield time

wintry prawn
#

thanls

#

how does this look i got both the forcefield and damagebricks to work

rose sleet
#

cool

#

is that a obby?

wintry prawn
#

ye

#

now i gotta know how to make a disappear and re-appear script for a part

wintry prawn
#

never mind i got it working

rose sleet
#

ok

wintry prawn
#

i got alot of stuff working now

hardy mica
#

keep it going, niceThumbs

crude epoch
#

yes

grim galleonBOT
#

studio** You are now Level 14! **studio