Hey devs, I am having issues with this. My issue is that if I try to put in the Red before the Blue, it does not work. If you need me to go more into depth please tell me, and if you know how to fix it also please tell me!
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "BlueStronium" then
script.Parent.Parent.BlueStronium.Union:Destroy()
script.Parent.Parent.BlueStronium.Part:Destroy()
script.B.Value = true
end
if hit.Parent.Name == "RedVibium" then
script.Parent.Parent.RedVibium.Union:Destroy()
script.Parent.Parent.RedVibium.Part:Destroy()
script.R.Value = true
end
if script.R.Value == true then
if script.B.Value == true then
if script.On.Value == true then
wait()
script.On.Value = false
game.Workspace.Purple.Text.Gui.Time.Text = "10"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "9"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "8"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "7"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "6"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "5"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "4"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "3"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "2"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "1"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = " "
script.Parent.Parent.Parium.Union.Transparency = 0.7
script.Parent.Parent.Parium.Part.Transparency = 0
script.Parent.Parent.Parium.Union.CanCollide = true
script.Parent.Parent.Parium.Part.CanCollide = true
script.Parent.Parent.Parium.Union.Anchored = false
script.Parent.Parent.Parium.Part.Anchored = false
script.Parent:Destroy()
end
end
end
end)
1 Like
Iām a bit confused so yes, are you wanting to check if the R
and B
AND On
values are all set to true?
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "BlueStronium" then
script.Parent.Parent.BlueStronium.Union:Destroy()
script.Parent.Parent.BlueStronium.Part:Destroy()
script.B.Value = true
end
if hit.Parent.Name == "RedVibium" then
script.Parent.Parent.RedVibium.Union:Destroy()
script.Parent.Parent.RedVibium.Part:Destroy()
script.R.Value = true
end
if script.R.Value and script.B.Value and script.On.Value then
wait()
script.On.Value = false
game.Workspace.Purple.Text.Gui.Time.Text = "10"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "9"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "8"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "7"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "6"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "5"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "4"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "3"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "2"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = "1"
wait(1)
game.Workspace.Purple.Text.Gui.Time.Text = " "
script.Parent.Parent.Parium.Union.Transparency = 0.7
script.Parent.Parent.Parium.Part.Transparency = 0
script.Parent.Parent.Parium.Union.CanCollide = true
script.Parent.Parent.Parium.Part.CanCollide = true
script.Parent.Parent.Parium.Union.Anchored = false
script.Parent.Parent.Parium.Part.Anchored = false
script.Parent:Destroy()
end
end)
1 Like
Try this?
local part = script.Parent
local model = part.Parent
part.Touched:Connect(function(hit)
if hit.Parent.Name == "BlueStronium" then
model.BlueStronium.Union:Destroy()
model.BlueStronium.Part:Destroy()
script.B.Value = true
elseif hit.Parent.Name == "RedVibium" then
model.RedVibium.Union:Destroy()
model.RedVibium.Part:Destroy()
script.R.Value = true
end
if not script.R.Value or not script.B.Value or not script.On.Value then
return
end
wait()
script.On.Value = false
for i = 10, 1, -1 do
workspace.Purple.Text.Gui.Time.Text = tostring(i)
end
workspace.Purple.Text.Gui.Time.Text = " "
model.Parium.Union.Transparency = 0.7
model.Parium.Part.Transparency = 0
model.Parium.Union.CanCollide = true
model.Parium.Part.CanCollide = true
model.Parium.Union.Anchored = false
model.Parium.Part.Anchored = false
part:Destroy()
end)
You had some repetition that could fixed via variables and looping which can clear up some confusing bits of the code, also I think it would be better to check all the 3 values immediately. Also, an if-elseif is better since a name cannot be 2 things
2 Likes
Why do you have this in there LOL
2 Likes
Yea I accidentally had 2 scripts to help out in the same notepad and I jsut did ctrl + a, thanks for notifying me haha
1 Like