I’m attempting to make a block appear then disappear, I found a free model that does this. But it makes a countdown appear above the block that appears and I want it to be above the button that activates this script.
script.Parent.BrickColor = BrickColor.new("Dark green")
b = game.Workspace.Part
b.CanCollide = false
b.Transparency = 1
local buttonactive = false
function onTouch()
if buttonactive == false then
buttonactive = true
displaytime(15)
else print ("Error - Already active!")
end
end
function displaytime(countdowntime)
local timer = Instance.new("BillboardGui")
timer.Parent = b
timer.Size = UDim2.new(0,50,0,50)
timer.StudsOffset = Vector3.new(0,5,0)
timer.AlwaysOnTop = true
local timertxt = Instance.new("TextBox")
timertxt.Parent = timer
timertxt.Size = UDim2.new(0,50,0,50)
timertxt.TextScaled = true
timertxt.TextColor3 = Color3.new(255,255,255)
timertxt.BackgroundColor3 = Color3.new(0,0,0)
timertxt.BorderColor3 = Color3.new(0,0,0)
timertxt.BackgroundTransparency = 1
function displaytime (countdowntime)
local bincountdown = countdowntime
timer.Enabled = true
b.CanCollide = true
b.Transparency = 0
script.Parent.BrickColor = BrickColor.new("Really red")
repeat
timertxt.Text = tostring(bincountdown)
bincountdown = bincountdown - 1
wait(1)
until
bincountdown < 1
timer.Enabled = false
buttonactive = false
b.CanCollide = false
b.Transparency = 1
script.Parent.BrickColor = BrickColor.new("Dark green")
end
script.Parent.Touched:connect(onTouch)
I tried adding another variable, but it broke the scrit
`a = game.Workspace.One[/code]
wait(0.1)
script.Parent.BrickColor = BrickColor.new("Dark green")
I tried adding another variable, but it broke the script
a = game.Workspace.One
any way to make it work? I don’t script much and have no idea what I’m doing and I modified code from the Roblox Lua website Variables
Also by broken i mean, the part that is supposed to be invisible isn’t invisible before the button is activated and the button doesn’t activate.
Bumping, still need a solution
I think we’re going to need more of an explanation of how the scene is setup (a screenshot of the explorer often does the trick) and a better explanation of exactly what is happening currently, and what you would like to happen.
Explorer
when I touch the button I want it to turn red and make the sphere visible with a countdown above it. I modified a free model but it makes a countdown appear above the block that is now visible and not the button. I tried adding another variable so the countdown spawns above the button, this broke the script and it no longer works. I’m looking for a solution to make the sphere appear when the button is activated and a countdown appear above the button.
could you format the code in the post i cant read
It appears that this line needs to be changed to whatever part you want the timer above. Which is the actual button part? is it somewhere relative to the script? Do you want the timer above one
or aPart
?
I have replaced it and left it in there for later reference. It is set to the correct part
Does it work correctly with those changes?
Yes, that script works as intended
It breaks when I try to make the Countdown be above the button
can you provide some information of what happens when it ‘breaks’? is there any errors in the output?
Location of error (same script as I stated in original post)
This is your original code, but edited based on the error.
script.Parent.BrickColor = BrickColor.new("Dark green")
b = game.Workspace.Part
b.CanCollide = false
b.Transparency = 1
local buttonactive = false
function onTouch()
if buttonactive == false then
buttonactive = true
displaytime(15)
else print ("Error - Already active!")
end
end
function displaytime(countdowntime)
local timer = Instance.new("BillboardGui")
timer.Parent = b
timer.Size = UDim2.new(0,50,0,50)
timer.StudsOffset = Vector3.new(0,5,0)
timer.AlwaysOnTop = true
local timertxt = Instance.new("TextBox")
timertxt.Parent = timer
timertxt.Size = UDim2.new(0,50,0,50)
timertxt.TextScaled = true
timertxt.TextColor3 = Color3.new(255,255,255)
timertxt.BackgroundColor3 = Color3.new(0,0,0)
timertxt.BorderColor3 = Color3.new(0,0,0)
timertxt.BackgroundTransparency = 1
end
function displaytime (countdowntime)
local bincountdown = countdowntime
timer.Enabled = true
b.CanCollide = true
b.Transparency = 0
script.Parent.BrickColor = BrickColor.new("Really red")
repeat
timertxt.Text = tostring(bincountdown)
bincountdown = bincountdown - 1
wait(1)
until
bincountdown < 1
timer.Enabled = false
buttonactive = false
b.CanCollide = false
b.Transparency = 1
script.Parent.BrickColor = BrickColor.new("Dark green")
end
script.Parent.Touched:connect(onTouch)
I tried adding another variable, but it broke the scrit
`a = game.Workspace.One[/code]
wait(0.1)
script.Parent.BrickColor = BrickColor.new("Dark green")
Alright that has made the sphere start invisible but it still doesn’t activate.