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

After block goes transparent (invisible) the block still does damage?

Asked by 4 years ago

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.

0
You cannot just simply make a brick invisible and think that .Touched won't work. You have to use an IF staTEmENt greatneil80 2647 — 4y
0
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 Xapelize 2658 — 4y

2 answers

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago

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.

0
by "Damage code" do you mean my actual damage script? or something else? stormaphobia 5 — 4y
0
The code that is responsible for damaging the player Ziffixture 6913 — 4y
Ad
Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago

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

0
Whenever i made a third script in my block, to insert this one^ the transparency and damage script stopped working stormaphobia 5 — 4y

Answer this question