Under a ProximityPrompt, I have a script that plays a random sound. However, I used math.random to generate a random integer, which was then used to play the random sound within its parented model. The problem is that a random value is picked once and then never modified.
This is the script I’m currently using
local coinsound = script.Parent.Parent.Insert
local Part = script.Parent.Parent
local ProximityPrompt = script.Parent
local RandomSound = math.random(2)
ProximityPrompt.Triggered:Connect(function(Player)
ProximityPrompt.Enabled = false
coinsound:Play()
wait(2)
local sound = Part["SoundName"..tostring(RandomSound)]
print(sound.Name..' played')
sound:Play()
wait(sound.TimeLength)
ProximityPrompt.Enabled = true
end)