So i created a music gui, and when u click a play button its going to play, but on the server. so when u click on the play button, then its going to fire a event, and its going to play and everybody can hear it, but what if i then want so if the player click pause and it fires the same event. its just going to play the song again. if that makes sense.
Client script
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent") script.Parent.Play.MouseButton1Click:Connect(function() if script.Parent.TextBox.TextBox.Text ~= "" then local Plr = game.Players.LocalPlayer local Asset = game.MarketplaceService:GetProductInfo(script.Parent.TextBox.TextBox.Text) script.Parent.SongName.Text = Asset.Name script.Parent.UploadedBy.Text = "Uploaded by "..Asset.Creator.Name RE:FireServer("rbxassetid://"..script.Parent.TextBox.TextBox.Text,"Play") end end) script.Parent.Pause.MouseButton1Click:Connect(function() RE:FireServer("rbxassetid://"..script.Parent.TextBox.TextBox.Text,"Pause") end) script.parent.Stop.MouseButton1Click:Connect(function() RE:FireServer("rbxassetid://"..script.Parent.TextBox.TextBox.Text,"Stop") script.Parent.SongName.Text = "" script.parent.UploadedBy.Text = "Uploaded by nobody" script.Parent.TextBox.TextBox.Text = "" end)
Server script
local RE =game.ReplicatedStorage:WaitForChild("RemoteEvent") RE.OnServerEvent:Connect(function(sender, ID,Gen) if Gen == "Play" then local Character = sender.Character if not Character:FindFirstChild("Sound") then local Sound = Instance.new("Sound",Character) Sound.SoundId = ID Sound.Looped = true Sound:Play() end if Gen == "Pause"then Character:FindFirstChild("Sound") end if Gen == "Stop" then Character:FindFirstChild("Sound"):Destroy() end end end)
u can see i tried with the if gen == "Play" then but it dosn't work
Are you sure you have written out your full script? If yes, then...
if Gen == "Pause"then Character:FindFirstChild("Sound") end
You'd add in :Pause() to pause the music:
if Gen == "Pause"then Character:FindFirstChild("Sound"):Pause() end