The break code works before the song ends
local sound_final = Instance.new("Sound")
sound_final.SoundId = "rbxassetid://1838673350"
sound_final.Looped = false
sound_final.Parent = workspace
game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
if assetId == 1402432199 then
sound_final:Play()
while true do
-- codes
if sound_final.Ended:Wait() then
break
end
end
end
end)
You don’t need the while true do loop:
game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
if assetId == 1402432199 then
sound_final:Play()
sound_final.Ended:Wait()
end
end)
1 Like
no there are other codes out there. I need the loop for those codes.
By using Wait you are guaranteeing that the loop will only ever run once.
You should probably show the missing code then as that could be part of your problem.
game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
if assetId == 1402432199 then
wait(1)
ChatService:Chat(Head, `A.`, "Red")
wait(1)
dance:Play()
wait(2)
celling_light1.Brightness = 0
celling_light2.Brightness = 0
celling_light3.Brightness = 0
spotlight.Brightness = 0
lamp2_light.Brightness = 0
celling_light1.LightEmission = 1
celling_light4.Transparency = 1
celling_light5.Transparency = 1
light1_1_part1.Transparency = 1
light1_2_part1.Transparency = 1
light2_1_part1.Transparency = 1
light2_2_part1.Transparency = 1
light2_1_part2.Transparency = 1
light2_2_part2.Transparency = 1
light3_1_part1.Transparency = 1
light3_2_part1.Transparency = 1
light3_1_part2.Transparency = 1
light3_2_part2.Transparency = 1
light4_1_part1.Transparency = 1
light4_2_part1.Transparency = 1
light4_1_part2.Transparency = 1
light4_2_part2.Transparency = 1
light5_1_part1.Transparency = 1
light5_2_part1.Transparency = 1
light5_1_part2.Transparency = 1
light5_2_part2.Transparency = 1
light6_1_part1.Transparency = 1
light6_2_part1.Transparency = 1
light6_1_part2.Transparency = 1
light6_2_part2.Transparency = 1
light7_1_part1.Transparency = 1
light7_2_part1.Transparency = 1
light7_1_part2.Transparency = 1
light7_2_part2.Transparency = 1
light8_1_part1.Transparency = 1
light8_2_part1.Transparency = 1
light8_1_part2.Transparency = 1
light8_2_part2.Transparency = 1
light1_1_light.Brightness = 0
light1_2_light.Brightness = 0
light2_1_light.Brightness = 0
light2_2_light.Brightness = 0
light3_1_light.Brightness = 0
light3_2_light.Brightness = 0
light4_1_light.Brightness = 0
light4_2_light.Brightness = 0
light5_1_light.Brightness = 0
light5_2_light.Brightness = 0
light6_1_light.Brightness = 0
light6_2_light.Brightness = 0
light7_1_light.Brightness = 0
light7_2_light.Brightness = 0
light8_1_light.Brightness = 0
light8_2_light.Brightness = 0
wait(3)
part1.CanTouch = true
part2.CanTouch = true
part3.CanTouch = true
part4.CanTouch = true
part5.CanTouch = true
part6.CanTouch = true
part7.CanTouch = true
part8.CanTouch = true
workspace.Dummy.HumanoidRootPart.Anchored = false
wait(0.5)
char.Humanoid:MoveTo(workspace.Location_Dummy.Position)
wait(2.6)
workspace.Security_parts.secuirty_part.CanCollide = false
wait(10)
ChatService:Chat(Head, `PARTY STARTING`, "Red")
wait(1)
ChatService:Chat(Head, `START MUSIC!`, "Red")
wait(1)
sound_final:Play()
while true do
local newcolor1 = randomColor()
local newcolor2 = randomColor()
local newcolor3 = randomColor()
local newcolor4 = randomColor()
local newcolor5 = randomColor()
local newcolor6 = randomColor()
local newcolor7 = randomColor()
local newcolor8 = randomColor()
local newcolor9 = randomColor()
local newcolor10 = randomColor()
local newcolor11 = randomColor()
local newcolor12 = randomColor()
local newcolor13 = randomColor()
local newcolor14 = randomColor()
local newcolor15 = randomColor()
local newcolor16 = randomColor()
local newcolor17 = randomColor()
wait(0.5)
light_real_neon.Color = newcolor17
light_real_pointlight1.Color = newcolor17
light_real_pointlight2.Color = newcolor17
light1_1_light.Color = newcolor1
light1_1_part1.Color = newcolor1
light1_2_light.Color = newcolor2
light1_2_part1.Color = newcolor2
light2_1_light.Color = newcolor3
light2_1_part1.Color = newcolor3
light2_2_light.Color = newcolor4
light2_2_part1.Color = newcolor4
light3_1_light.Color = newcolor5
light3_1_part1.Color = newcolor5
light3_2_light.Color = newcolor6
light3_2_part1.Color = newcolor6
light4_1_light.Color = newcolor7
light4_1_part1.Color = newcolor7
light4_2_light.Color = newcolor8
light4_2_part1.Color = newcolor8
light5_1_light.Color = newcolor9
light5_1_part1.Color = newcolor9
light5_2_light.Color = newcolor10
light5_2_part1.Color = newcolor10
light6_1_light.Color = newcolor11
light6_1_part1.Color = newcolor11
light6_2_light.Color = newcolor12
light6_2_part1.Color = newcolor12
light7_1_light.Color = newcolor13
light7_1_part1.Color = newcolor13
light7_2_light.Color = newcolor14
light7_2_part1.Color = newcolor14
light8_1_light.Color = newcolor15
light8_1_part1.Color = newcolor15
light8_2_light.Color = newcolor16
light8_2_part1.Color = newcolor16
if sound_final.Ended:Wait() then
break
end
end
end
end)
DasKairo
(Cairo)
March 18, 2023, 5:04pm
#7
See this is why you use for
loops.
mhmdsndb3
(Printer)
March 18, 2023, 5:05pm
#8
Why are you using if statement
Just
sound.Ended:Wait()
break
Also it breaks because if statement checks if its a function that exist
Also
local sound_final = Instance.new("Sound")
sound_final.SoundId = "rbxassetid://1838673350"
sound_final.Looped = false
sound_final.Parent = workspace
local IsSoundEnded = false
sound_final.Ended:connect(function()
IsSoundEnded = true
end
game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
if assetId == 1402432199 then
sound_final:Play()
while true do
-- codes
if IsSoundEnded == true then
break
end
end
end
end)
mhmdsndb3
(Printer)
March 18, 2023, 5:08pm
#9
Use
for i, v in pairs(workspace.Lights:GetChildren () do
v.Brightness = number
end
It will save you 100 lines of code
Okay thanks but have problem:
if IsSoundEnded == true then
break
end
end
end
end)
Entildo
(Fase)
March 18, 2023, 5:26pm
#11
Pretty clear error, you either have too many ends or not enough ends, go hover over it and see what it says, we cannot tell from this much code.
Could you explain a little more what this code does?
mhmdsndb3
(Printer)
March 18, 2023, 8:53pm
#14
Connects the .ended with a function to make a variable true so when the if statement checks it
It gets the variable meaning instead of checking if the wait function exist
mhmdsndb3
(Printer)
March 18, 2023, 9:00pm
#15
Oh i mixed
The for i,v loop makes the script run for everything in the table
GetChildren returns a table with every child inside object so if we use for i,v loop on it it will do your task on all parts
Example:
for i,v in pairs(workspace:GetChildren()) do -- looping through all children in workspace
v:Destroy() --destroys the child
end
You can read more about it on Google
Really simple but can save you alot of time
system
(system)
Closed
April 1, 2023, 9:00pm
#16
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.