I am scripting noob, so I'm doing simple things, so i made a transparency script so it appears then disappears, and i added a damage script so when its actually visible, it hurts, but when its invisible it does no damage, I don't know if there's a script where you can make it hurt at certain times but, i have no idea how to execute this.
After block goes transparent (invisible) the block still does damage?
2 answers
This can be achieved by using if statements, otherwise known as conditionals. This allows you to execute a scope of code primarily depended on a certain condition, for this, will be if the brick is transparent. The lines of code to achieve this goal are just below!
local brick = workspace.Brick -- replace the part name if needed
if (brick.Transparency ~= 1) then
-- Damage code goes within this scope
end
Hope this helps! If so, don't forget to accept this answer! If you have any more questions or troubles, please comment below.
2 comments
by "Damage code" do you mean my actual damage script? or something else?
The code that is responsible for damaging the player
Make the script like this (Remember to put this script into your 'block') :
script.Parent.Name = "CanDamages"
local part = script.Parent
local damageScript = script.Parent.DamageScript -- Rename it to your damage script name
if part.Transparency == 1 then -- if the part INVISIBLE,
damageScript.Enabled = false -- DamageScript might get disabled (the script can't work)
else -- if the Transparency is other else 1
damageScript.Enabled = true -- The 'block' is damagable
end -- the end of the script
IMPORTANT: Make the line 4 'DamageScript' become your DamageScript name.
Hope I helped, Have a nice day and hope you happy coding :D
I glad to help you :)
1 comment
Whenever i made a third script in my block, to insert this one^ the transparency and damage script stopped working
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You cannot just simply make a brick invisible and think that .Touched won't work. You have to use an IF staTEmENt
use if , if the block transparency is 0, the damage script might no works. otherwise the block might hurt you. You can make the damage script undamagable by doing the script.Enabled = false. I've already answered, hope I helped you :) lol i say too much