/play <SOUNDID> not working

Code Support

Sorry, I’ve got nothing for you on this regard. You’ve said that your code is not working, but you have not provided nearly enough information for me to go off of. What exactly is the problem? Have you tried debugging this yourself by adding prints in your code? Have you checked your developer console? You need to take preliminary steps to try and debug your code first before you reach for assistance.

Please see the category guidelines before making posts. It’ll save you and those who are trying to help you quite a bit of time to get working on the problem, rather than trying to find out first what the root of it even is.


Code Review

  • You should validate that the return arguments of WaitForChild and/or FindFirstChild are not nil first before you try calling any methods on them.
  • The first expression in WeldRadio… has no real point.
  • Index services by GetService, not using direct dot syntax. This is both a canon way of fetching services and what should be done.
  • Call UserOwnsGamePassAsync once and associate the return to the player; there’s no need to call it so many times in your function
  • You should wrap all your code in “does player own pass?” instead of connecting whether a player owns it or not. You can update the variable somewhere else. It’d be easier on you, frankly and it’s good practice. Remember that UserOwnsGamePassAsync is a web call and it can fail - I don’t have it in my example, but you should wrap it in a pcall.
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")

Players.PlayerAdded:Connect(function (plr)
    local UserHasRadio = MarketplaceService:UserOwnsGamePassAsync(args_here)
    local radio = Instance.new("BoolValue")
    radio.Name, radio.Parent = "radio", plr
    radio.Value = UserHasRadio
    if UserHasRadio then
        plr.CharacterAdded:Connect(function ()
            WeldRadio(plr)
        end)
        plr.Chatted:Connect(function (message)
            -- your code
        end)
    end
end)
  • ^ Obviously don’t use this raw, it’s simply an example of how you can improve your current code so that you receive the benefits of both
    • A. Being able to potentially debug easier
    • B. Having a centralised, easy way to contain all your logic for those with a pass and those without
1 Like