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.
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.
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 :)