Hi, I am making a spike system for my game that will pop up and go back down. While the spike is popping up, I would like to play a sound effect with it. I made the script to play the tween and sound but the sound is not synced with the playing tween. Here is my code so far:
local Part = script.Parent
local TweenService = game:GetService("TweenService")
local sound = Part.Sound
local StartPos = Part.Position
local Goal = {}
Goal.Position = Vector3.new(StartPos-Vector3.new(0, 80, 0),StartPos)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
-1,
true,
4
)
local tween = TweenService:Create(Part, tweenInfo, Goal)
tween:Play()
wait(5)
while true do
sound:Play()
wait(8)
end
Is it something to do with timing? Or is it something else? Please help me.

1 comment
That won't work, as it will check the position as soon as the script runs. Use ":GetPropertyChangedSignal(prop)"