Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

im trying to make a block grow and shrink at random times and its not working plz help[Solved]?

im making a boss battle in my rpg BaconRPG and idk how to make the beam thats gonna get fired fire.

heres my script

local Beam = script.Parent
local ReloadTime = math.random(1,10)

 ReloadTime.Changed:connect(function()
Beam.Size = Vector3.new(1,1,4)
wait(ReloadTime)
Beam.Size = Vector3.new(55,1,4)
wait(1)
local ReloadTime = math.random(1,10)
end)

1 answer

✓ Accepted answer

Hi! .Changed would not work because "ReloadTime" is a number value. So for you, I changed it to while wait(1) do. Even if .Changed did work, it would do nothing since you aren't actually changing it until the end of your function.

local Beam = script.Parent
local ReloadTime = math.random(1,10)

while wait(1) do 
	ReloadTime = math.random(1,10)
Beam.Size = Vector3.new(1,1,4)
wait(ReloadTime)
Beam.Size = Vector3.new(55,1,4)
wait(1)
local ReloadTime = math.random(1,10)
end

Now that code will work, but if you truly want it to be random not just 1 or 10, Id recommend adding a math.randomseed(tick()) so the wait will be between 1 and 10 not just 1 or 10.

local Beam = script.Parent
local ReloadTime = math.random(1,10)
math.randomseed(tick()) -- <----

while wait(1) do 
	ReloadTime = math.random(1,10)
Beam.Size = Vector3.new(1,1,4)
wait(ReloadTime)
Beam.Size = Vector3.new(55,1,4)
wait(1)
local ReloadTime = math.random(1,10)
end

And if you really want , you can make the beam sizes random too. If this helped, please accept, otherwise tell me so.

1 comment

0

thx this help out a lot

This discussion is preserved as it was. New answers, comments, and votes are closed.