-- Client Side
local plr = game.Players.LocalPlayer
local remote = game:GetService("ReplicatedStorage").Remotes.skip
local remote2 = game:GetService("ReplicatedStorage").Remotes.request

plr.Chatted:connect(function(message)
	if message:sub(1,6) == "-Play " or message:sub(1,6) == "-play " then
		local songId = message:sub(7)
		remote2:FireServer(songId)
	elseif message:sub(1,6) == "-Skip" or message:sub(1,6) == "-skip" then
		remote:FireServer()
	end
end)
-- Client Side
-- Server Side
local main = workspace.Music.Screen.screen.SurfaceGui:WaitForChild("mainscreen")
local music = workspace:WaitForChild("BackgroundMusic")
local playlist = require(script.musicplaylist)
local progress = main:FindFirstChild("ProgressBar").Progress
local songName = main:FindFirstChild("SongName")
local MServ = game:GetService("MarketplaceService")
local gamepass = 4112130
local allowed = {'Ize_Cubz','zxcvbnm30000','Aika_Mei'}

local PlayMusic = coroutine.create(function()
	local ToPlay = playlist[math.random(1,#playlist)]
	local asset = game:GetService("MarketplaceService"):GetProductInfo(ToPlay)
	local name = asset.Name
	music.SoundId = 'rbxassetid://'..tostring(ToPlay)
	songName.Text = (name)
	music:Play()
	progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(music.TimeLength)-1)
	wait((music.TimeLength)-1)
end)

coroutine.resume(PlayMusic)

function PlayCustomSong(plr,songId)
	if MServ:UserOwnsGamePassAsync(plr.UserId,gamepass) or plr.Name == "Ize_Cubz" then
	coroutine.yield(PlayMusic)
	local ToPlay = songId
	local asset = game:GetService("MarketplaceService"):GetProductInfo(ToPlay)
	local name = asset.Name
	music.SoundId = 'rbxassetid://'..ToPlay
	songName.Text = (name)
	music:Play()
	progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(music.TimeLength)-1)
	wait((music.TimeLength)-1)
	PlayMusic()
	else
	MServ:PromptGamePassPurchase(plr,gamepass)
	end
end


game.ReplicatedStorage.Remotes.skip.OnServerEvent:connect(function(plr,skipkey)
	if MServ:UserOwnsGamePassAsync(plr.UserId,gamepass) or plr.Name == "Ize_Cubz" then
	coroutine.yield(PlayMusic)
	wait(0.5)
	coroutine.resume(PlayMusic)
	else
	MServ:PromptGamePassPurchase(plr,gamepass)
	end
end)

game.ReplicatedStorage.Remotes.skip.OnServerEvent:connect(PlayCustomSong)

music.Ended:connect(function()
	coroutine.yield(PlayMusic)
	wait(1)
	coroutine.resume()
end)
-- Server Side

When I run the "-skip" command in the chat it gives me a error

23:04:43.872 - Unable to cast string to int64 23:04:43.872 - Stack Begin 23:04:43.873 - Script 'ServerScriptService.Music', Line 27 23:04:43.873 - Stack End

Also when I run the "-play" command in chat it doesn't do anything at all, it gives no errors too.

When the progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(music.TimeLength)-1) part is done it just goes to the end without tweening.

When the song is done it just plays over again, even though I don't have loop enabled on the sound.

5 comments

0

Sorry for the really crammed script, I tried separating it. (I'm sorta new to scripting helpers)

0

You shouldn’t handle the chatted event from the client; this can benefit the exploiter.

0

How would it benefit the exploiter, the server script checks if they have a gamepass and only works if they have it.

0

Right. But exploiters still have workarounds to these things. Handle the chatted event on the server. FilteringEnabled logic: Never trust the client.

0

Plus, when you chat, does everyone see it or only you? Everyone sees it. Shouldn’t handle things that replicates to the server.