I’m working on a script for a sword. The script highlights the enemy red indicating that you hit them before damaging them. The problem is that the damage only works after the highlight animation plays.
Highlight script:
local function light(glow) --Highlights the hrp
for i = 0,math.floor(50/speed),1 do
glow.FillTransparency -= .01*speed
wait(0)
end
for i = 0,math.floor(50/speed),1 do
glow.FillTransparency += .01*speed
wait(0)
end
print("Done")
end
Thats probably because there is a loop in the way, One of the main things you have to remember about Loops is that they yield the Thread until they are broken, which would mean that they will not run any code after them until they are gone, A Simple solution would be to have them run in a separate thread, or run separately from the current code going on, which can be done by using the coroutine library or the task library.