-
What do you want to achieve? Keep it simple and clear!
I want a sound to play locally for a player in very fast succession. -
What is the issue?
While using a while true loop the sound will play very fast jut fine like I want it to but when I want it to be played after a GetPropertyChangedSignal event fire it might only play once or twice.
The numbers in the console pop up when the sound should be played
-
What solutions have you tried so far?
I tried creating a new instance of the sound, playing, and destroying it but it does the same thing as SoundService:PlayLocalSound(tickSound) does.
local SoundService = game:GetService("SoundService")
local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local ScrollBox = PlayerGui:WaitForChild("ScreenGui").MainFrame.ScrollBox
local tickSound = script.Sound
local lastFound = 0
--while wait() do
-- game:GetService("SoundService"):PlayLocalSound(tickSound)
--end
ScrollBox:GetPropertyChangedSignal("Position"):Connect(function()
local boxPosition = ScrollBox.Position
local truncatedPosition = math.floor(boxPosition.X.Scale*10)/10
if truncatedPosition % .2 == 0 then
if lastFound ~= truncatedPosition then
print(truncatedPosition)
lastFound = truncatedPosition
SoundService:PlayLocalSound(tickSound)
end
end
end)