Hello, last time I made a post to fix a bug, but now I have a bigger problem, now when I create this command it allows the member with the appropriate gamepass can use this command.
However if a member uses it or I use it everything works, but the problem is that when we use another command the game thinks that we are doing just this command, the same when we speak in the game without using a command, I don't not even know why when we speak the game understands that it is a command it tries to modify the music while we do not ask since we are only talking and not using the command.
My Script :
game.Players.PlayerAdded:Connect(function(plr) local marketPlace = game:GetService("MarketplaceService") local admin = false local owner = false local canChangeMusic = false --local canChangeVolOfMusic = false --local canTP = false if plr.UserId == 96919359 or plr.UserId == 155674478 then owner = true admin = true canChangeMusic = true --canChangeVolOfMusic = true --canTP = true end if marketPlace:UserOwnsGamePassAsync(plr.userId, 11275677) then canChangeMusic = true --canChangeVolOfMusic = true --canTP = true end plr.Chatted:connect(function(msg) if string.sub((msg),1,9) == "/musicid " and admin or owner or canChangeMusic then local a = string.sub(msg,10) game.Workspace:FindFirstChild("Music").SoundId = "rbxassetid://"..a game.Workspace:FindFirstChild("Music").Volume = 0.1 game.Workspace:FindFirstChild("Music").Playing = true game.Workspace:FindFirstChild("Music").TimePosition = 0 end end) end)
You can make it like an admin command:
local SS = game:GetService("SoundService") local adminUserIds = { User ID, User ID } function isAdmin(playerUserID) for _,item in pairs(adminUserIds) do if playerUserID == item then return true end end end game.Players.PlayerAdded:Connect(function(plr) if isAdmin(plr.UserId) then plr.Chatted:Connect(function(msg) if string.split(msg," ")[1] == "/musicid" then local id = string.split(msg," ")[2] local sound = Instance.new("Sound",SS) sound.SoundId = "rbxassetid://"..(id) sound.Looped = true sound.Volume = 0.1 sound:Play() end end) end end)
With this script, when the player chats /musicid (sound id), then a sound with the desired id will play.
I am not very good with the MarketplaceService, so I suppose you can make a script that when a player buys a gamepass, their user id will be stored into the admins table.