Hi, I tried making a button that only morphs you if you have a special gamepass/badge. (I will change it to a badge later) I made this script:
local player = game.Players.LocalPlayer
local gamepass = 915027207
function morph()
--censoring just so nobody steals ;-;
end
script.Parent.MouseButton1Click:connect(function()
local allow = (
game:GetService('MarketplaceService'):PlayerOwnsAsset(player.userId, gamepass) or
game.CreatorId == player.userId
)
if allow then
morph()
else
script.Parent.Text = "Not enough Points!"
script.Parent.TextColor3 = Color3.new(255,0,0)
wait(1)
script.Parent.Text = script.Parent.Name
script.Parent.TextColor3 = Color3.new(0,0,0)
end
end)
but I get this error "Unable to cast value to Object" and the button results in doing absolutely nothing. Please help!

2 comments
I've believe there is no error. Might just have been the morphing function.
@thesit123 my bad, i fixed it. thanks!