Hello, I am making a tycoon, and I am currently trying to get a game pass working. The game pass, if the player has it should allow the player to step on a button and get a 10% chance to have a VIP block spawn on the droppers every time the droppers spawn a part, My issue, is that my script isn't working properly.
script:
local gamePassId = 445136135
local passService = game:GetService("MarketplaceService")
function vip(player)
if passService:PlayerOwnsAsset(player, gamePassId) then
print(player.Name .. " has the game pass!")
script.Parent.Parent.Parent.VIP.Value = "true"
else
print(player.Name .. " doesn't have the game pass...")
end
end
vipbutton = script.Parent.Head
vipbutton.Touched:connect(vip)
This script was provided as an answer to one of my previous questions. If I step on it in the "Studio Run" phase, I get an error on line "5": error:
01:13:38.925 - MarketplaceService:PlayerOwnsAsset() player should be of type Player, but is of type Part
The only idea I could get from this is to make the button used to call this script only accept player interaction, I'm not sure what this would fix but just a hunch. I wouldn't know how to do this though. I tried the other method for getting a game pass detected, but when I stepped on the button I got an error saying invalid player. I figured it was because I was running it in the studio, but when I tried it on a ROBLOX SERVER, the button faded as it's supposed to, but the VIP.Value was not set to "true".
So how could I get the button to properly detect that the player has a game pass and to change the VIP.Value to set equal to "true" so that the ability will be enabled on my map when ever a dropper checks for it?
Any insight would be appreciated, I'm at a dead end with my noobish abilities.
Thanks in advance!
In case you needed to see: scripts associated. Clicker Dropper script:
wait(2)
workspace:WaitForChild("PartStorage")
deb = true
script.Parent.Clicker.ClickDetector.MouseClick:connect(function(wat)
local vipblock = math.random(1,10)
local luckyblock = math.random(1,100)
if luckyblock == 1 and deb == true then
deb = false
local part = game.ReplicatedStorage.luckyhyperbit:Clone()
part.Parent = game.Workspace
print("luckyblock")
part.Name = "luckyhyperbit"
local cash = Instance.new("IntValue",part)
cash.Name = "Cash"
cash.Value = 15 -- How much the drops are worth
part.CFrame = script.Parent.Drop.CFrame - Vector3.new(0,1.3,0)
part.FormFactor = "Custom"
part.Size=Vector3.new(1.5, 1.5, 1.5) -- Size of the drops
part.TopSurface = "Smooth"
part.BottomSurface = "Smooth"
game.Debris:AddItem(part,20) -- How long until the drops expire
wait(.15)
deb = true
elseif luckyblock ~= 1 then
if script.Parent.Parent.Parent.VIP.Value == "true" and deb == true and vipblock == 1 then
deb = false
local part = game.ReplicatedStorage.viphyperbit:Clone()
part.Parent = game.Workspace
part.BrickColor = BrickColor.Random()
print("vipblock")
part.Name = "viphyperbit"
local cash = Instance.new("IntValue",part)
cash.Name = "Cash"
cash.Value = 10 -- How much the drops are worth
part.CFrame = script.Parent.Drop.CFrame - Vector3.new(0,1.3,0)
part.FormFactor = "Custom"
part.Size=Vector3.new(1, 1, 1) -- Size of the drops
part.TopSurface = "Smooth"
part.BottomSurface = "Smooth"
game.Debris:AddItem(part,9) -- How long until the drops expire
wait(.15)
deb = true
else
deb = false
local part = Instance.new("Part",workspace.PartStorage)
part.BrickColor=script.Parent.Parent.Parent.DropColor.Value
part.Material=script.Parent.Parent.Parent.MaterialValue.Value
local cash = Instance.new("IntValue",part)
cash.Name = "Cash"
cash.Value = 1 -- How much the drops are worth
part.CFrame = script.Parent.Drop.CFrame - Vector3.new(0,1.3,0)
part.FormFactor = "Custom"
part.Size=Vector3.new(1, 1, 1) -- Size of the drops
part.TopSurface = "Smooth"
part.BottomSurface = "Smooth"
game.Debris:AddItem(part,20) -- How long until the drops expire
wait(.15)
deb = true
end
end
end)
player join script, using other game pass detection method.
local gamePassId = 445136135
game.Players.PlayerAdded:connect(function(player)
if game:GetService("GamePassService"):PlayerHasPass(player, gamePassId) then
print(player.Name .. " has the game pass!")
else
print(player.Name .. " doesn't have the game pass...")
end
end)
I don't know what else would need to be seen.

2 comments
Why would you have connect call "part"? That isn't defiened in this script whats so ever. Other than that it looks good haha.
Thanks for the script reguardless, I just changed the button back to call the vip function and added your additoins, thanks a ton!