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.
You can play the sound when the spike is in a certain position, kinda like this maybe, hope this helps!
local spike = -- your spike thing local sound = -- your sound when true do if spike.Position >= Vector3.new() then --the position when it's popping up sound:Play end wait() end