I have a working script that is basically just a tool that plants a bomb. as you can see I use wait() to tell the bomb when to change color and when to explode. But I’m aware using wait() is a malpractice. Unfortunately, i’m an amateur scripter and i don’t know my options. Can anyone give me some pointers?
local Tool = script.Parent
local bomb = Tool.Handle
Tool.Activated:Connect(function()
local bomb_decoy = bomb:Clone()
bomb_decoy.CanCollide = true
bomb_decoy.Parent = workspace
bomb_decoy.Anchored = false
local x = 5
while x > 0 do
wait(0.5)
bomb_decoy.BrickColor = BrickColor.new("Really red")
wait(0.5)
bomb_decoy.BrickColor = BrickColor.new("Really black")
x = x - 1
end
if x == 0 then
bomb_decoy.Transparency = 1
bomb_decoy.Anchored = true
local explosion = Instance.new("Explosion")
explosion.Parent = workspace
explosion.Position = bomb_decoy.Position
explosion.BlastPressure = 100000
bomb_decoy:Destroy()
end
end)
thanks to all the responses. I was needing the insight because i was going to have a lot of these ticking bombs, and i need the countdown to be psuedo real-time. i guess i should have mentioned that in the original post thanks again !
I have custom wait that can go way lower and give way accurate results than task.wait().
It can currently do 0.001 wait and be more accurate than task.wait().
results like this:
0.001004878788
0.00108575755
0.00109575775
0.00100487575