Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I am having trouble with this sound script?It play at different timing if a player lags.

Asked by 4 years ago
Edited 4 years ago

while true do wait(0) script.Parent.MallMusic.Playing = true wait(35) script.Parent.MallMusic.Playing = false wait(100000) end

The problem is that sometimes it glitches out and play at different timing than it should according to the script if a player lags.(A Small Delay)

0
If you are wanting the sounds to sync up on all clients, you need to have the server control the audio. ForeverBrown 356 — 4y
0
also...whats the point of waiting 100,000 seconds? ForeverBrown 356 — 4y
0
XD 123nabilben123 499 — 4y
0
Ummm i was trying to make a camping game so it's based on a story so like after the music end it will stop forever thats why i put 10000000 Aqil_Whiz 2 — 4y
0
If you don't want the sound to ever play again, simply doing Script.Parent.MallMusic:Stop() will do. The sound will only play if you use :Play() or set playing to true. There is no use putting a long wait at the end of your code :) ForeverBrown 356 — 4y

2 answers

Log in to vote
0
Answered by
Robowon1 323 Moderation Voter
4 years ago

Is this in a local script? If so, the timing of the audio depends on the client not the server.

0
But whats a client? Aqil_Whiz 2 — 4y
0
and the difference between local script and script? Aqil_Whiz 2 — 4y
0
Aqil read of this article to learn about the difference between client and server ForeverBrown 356 — 4y
Ad
Log in to vote
0
Answered by
iuclds 720 Moderation Voter
4 years ago
Edited 4 years ago

The problem is either your internet is very slow or something else. I've made a few enhancments to your code for future use.

Dont use Playing = false or Playing = true, instead use :Stop() , :Resume() , or :Play()

spawn(function()
while true do
wait() 
script.Parent.MallMusic:Play() 
wait(35) 
script.Parent.MallMusic:Stop() 
wait(100000)
end
end)
0
on local script or script Aqil_Whiz 2 — 4y

Answer this question