Hello,
I've been trying to get this script to work for a long time. It's supposed to check if a player has a gamepass and execute some code, however this one line keeps throwing errors.
This script is in a ScreenGUI in StarterGUI
local plr = script.Parent.Parent.Parent.Parent local first = script.Parent.First first.MouseButton1Click:Connect(function() if game:GetService('GamePassService'):PlayerHasPass(plr.Name, 966815211) then -- Line has been removed to prevent copies end end)
The function "MouseButton1Click" is called and works fine, however the next line keeps throwing errors.
Yes, I've tried using MarketplaceService:PlayerOwnsAsset and in the output, it recommends using GamePassService:PlayerHasPass.
Any help would be much appreciated. :)
http://wiki.roblox.com/index.php?title=API:Class/GamePassService/PlayerHasPass
Yry to remove the .Name from plr.Name
For starters, you can only use MarketPlaceService in a server script when you're checking to see if the player has a pass. Secondly, when passing the player argument their name shouldn't be included. PlayerHasPass(Player, 966815211)
.
So if done correctly it should output the player's name.
first.MouseButton1Click:Connect(function() if game:GetService('GamePassService'):PlayerHasPass(plr.Name, 966815211) then print("Player.Name") end end)