-
What do you want to achieve? Keep it simple and clear!
Simply put, tried to make a script that when a part (lets call it part A) is touched, it will run a countdown for loop. When the countdown ends, part B’s properties will change. When you touch part A again after part B’s property change already ran, part B’s properties will change again.
Code i’m having issues with:
local startLine = script.Parent
local startPosition = game.Workspace.StartEr
local countDown = game.Workspace.CountDown
local countText = countDown.SurfaceGui.TextLabel
local winnerName = game.Workspace.WinnerName
local winnerText = winnerName.SurfaceGui.TextLabel
countText.Text = ("Countdown hasnt started")
local countdownDuration = 5
local startOn = false
local countdownOn = false
local startTouch = false
local function startCount()
for counting = countdownDuration, 0, -1 do
countdownOn = true
countText.Text = counting
wait(1)
end
startOn = true
startLine.Transparency = 0.6
startLine.CanCollide = false
countText.Text = ("GAME START")
winnerText.Text = ("Who will become the champion?")
print("OPEN THE GAME!")
wait(4)
countText.Text = ("WE ARE HYPE OUT HERE TODAY!")
wait(4)
if startOn == true then
startPosition.Touched:Connect(function(touchoff)
local humanoid = touchoff.Parent
local realHuman = humanoid:FindFirstChildWhichIsA("Humanoid")
if humanoid and startOn == true then
startOn = false
print("hoh")
startLine.Transparency = 0
startLine.CanCollide = true
countText.Text = ("Game End YARR YARR")
startLine.Transparency = 0
winnerText.Text = (realHuman.Parent.Name.." has won")
end
wait(3)
countText.Text = ("Countdown hasnt started")
countdownOn = false
startTouch = false
end)
end
end
startPosition.Touched:Connect(function(touchings)
local human = touchings.Parent
local fullHuman = human:FindFirstChildWhichIsA("Humanoid")
if fullHuman and startTouch == false then
startTouch = true
print("accurate condition")
startCount()
end
end)
-
What is the issue? Include screenshots / videos if possible!
The issue appears only after i run the function for the first time, and if i try to make it run again by touching the startPosition part, it will run the script with the “acccurate condition” print multiple times and ruin the script. So i want to make it actually run without any problems the second time i touch it.
Video : robloxapp-20210511-1621301.wmv (6.9 MB)
(mind the bad quality)
Printing to prove that it happened multiple times :
(issues happened after second accurate condition print) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried playing with the bool values, because that’s the only thing thats keeping the scripts from running multiple times.