Loop not working for script

I’m working on a game where you got find a monster on your screen in a certain amount of time and everything works but whenever the loop restarts the decal doesn’t became visible again.

–Here’s the script

local Monster= game.Workspace.SpookyMonster
local OriginPosition = game.Workspace.SpookyMonster.Position.Z
local ReactionTime = 20

function GetRandomPosition(part)

local x=math.random(-50.156, -46.506)
local y=math.random(1.5,33.65)
local z=math.random(-129.493,-44.393)
return Vector3.new(x,y,z)

end

while true do
print(“repeat”)
Monster.Position = GetRandomPosition()
task.wait(ReactionTime)
if Monster.Decal.Transparency == 1 then
ReactionTime -= 0.5
Monster.Decal.Transparency = 0
else
game.Workspace.b.CanCollide=false
print(“LOST”)
end
end

Cant figure it out and could use some help.

local i = 0
while true do
i = i + 1
print(“repeat”)
Monster.Position = GetRandomPosition()
task.wait(ReactionTime)
if Monster.Decal.Transparency == 1 then
ReactionTime -= 0.5
if i == 1 then
Monster.Decal.Transparency = 0
end
else
game.Workspace.b.CanCollide=false
print(“LOST”)
end
end

– The issue is because your setting the transparency of the decal to 1 each time the loop alliterates

now the part won’t move to a different location or become visible

im using a local script that makes it to where when your mouse touches the part the decal becomes invisible

local i = 0
while true do
i = i + 1
print(“repeat”)
Monster.Position = GetRandomPosition()
task.wait(ReactionTime)
ReactionTime -= 0.5
if i >= 1 then
Monster.Decal.Transparency = 0
end
end

thanks for the help with this!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.