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)
game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
if assetId == 1402432199 then
sound_final:Play()
sound_final.Ended:Wait()
end
end)
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)
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
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