I’ve been recently making a script where if a proximity prompt is triggered then a sound will be played. So I have 2 sounds in my soundService and in the script I load them with the :PreloadAsync()
function.
Here’s the script:
local SoundService = game:GetService("SoundService")
local ContentProvider = game:GetService("ContentProvider")
local Sound1 = SoundService:WaitForChild("Sound1")
local Sound2 = SoundService:WaitForChild("Sound2")
ContentProvider:PreloadAsync({Sound1})
ContentProvider:PreloadAsync({Sound2})
local parent = script.Parent.Parent.Parent.Parent
script.Parent.Triggered:Connect(function()
for index, value in pairs(parent:GetChildren()) do
if value.Color == Color3.fromRGB(255, 227, 84) and value.SurfaceGui.TextLabel.Text ~= parent.SurfaceGui.TextLabel.Text then
Sound1:Play()
elseif value.Color == Color3.fromRGB(255, 227, 84) and value.SurfaceGui.TextLabel.Text == parent.SurfaceGui.TextLabel.Text then
Sound2:Play()
end
end
end)
Don’t mind the mess of the script, all that you need to know is when a proximity prompt is triggered it checks all the parts in a model and then if a part is the color == Color3.fromRGB(255, 227, 84) and the part’s textLabel number does not equal to the floor that player is currently at, then sound 1 will be played, but the problem is both of the them play, even though I specified just one of them. But when it gets to the elseif
statement where if the color is Color3.fromRGB(255, 227, 84)
but the player is at the floor number equal with the number textLabel of that color part it should play a different sound but in this case it doesn’t play anything. What is the issue?