I want my Stereo model (with a click detector inside) to bring up the GUI that allows a player with the stereo gamepass to play an audio for a certain sound area.
What is the issue?
Previously this had worked, but now it’s somehow bugged so I’m unsure if it’s something that has changed!
What solutions have you tried so far?
I checked output and it came up with the error “unable to cast value to object”. After looking around on the internet all the solutions I found didn’t seem to solve the issue.
script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(function(player)
if OwnsGamepass(player.UserId, 18243189) or PlayerIsWhitelisted(player) then
player.PlayerGui.StereoGui.Enabled = true
else
game:GetService("ReplicatedStorage"):WaitForChild("Stereo"):FireClient(player)
end
end)
This server script is inside the part that should be clicked alongside the click detector. There is more before this which addresses the gamepass and whitelist etc.
Not sure if it’s something super simple and I’ve completely dumbed out on this?
local MarketplaceService = game:GetService("MarketplaceService")
function OwnsGamepass(userId, gamepassId)
local success,result = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, userId, gamepassId)
if not success then
result = false
end
return result
end
local whitelist = { "Naomicatlady3", "SirNebsalot", "asyIunz", "XxXMackenziee", "Verified_Players", "T3ddy_Bxar" }
function PlayerIsWhitelisted(player)
for i, v in pairs(whitelist) do
if v:lower() == player.Name:lower() then
return true
end
end
return false
end
script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(function(player)
if OwnsGamepass(player.UserId, 18243189) or PlayerIsWhitelisted(player) then
player.PlayerGui.StereoGui.Enabled = true
else
game:GetService("ReplicatedStorage"):WaitForChild("Stereo"):FireClient(player)
end
end)
This is the entirety of the server script. and here is the local script inside the GUI:
I’m just a bit confused since it has been working for ages and since it’s stopped it’s turned into a panic since people have spent money on this so it ideally needs to be sorted fast. so far I’ve temporarily disabled the gamepass for purchase due to this as I don’t want more people to buy it when it currently doesn’t work anymore!
any advice would be greatly appreciated. The script was made by a previous scripter for a game we both worked on. My knowledge on scripting isn’t too advanced, and the scripture has actually vanished completely so I cannot contact him!
Thanks so much! I had a sneaking suspicion it was to do with that, but it looks like my whitelist will no longer work because of this. Perhaps it’s due to a recent change since it’s happened with my other game passes too!