I was trying to check if a player has a game pass when they click a gui,but the problem is that i can only check that on roblox server side. Is there some way to check it other then when a player enters?
Module script
local module = {} local HatPackOne = 223106881 local HatPackTwo = 2 function Authin(player,Pack) return game:GetService("GamePassService"):PlayerHasPass(player,Pack) end module.Auth1 = function(player) Authin(player,HatPackOne) end return module
Script in a gui
local P = game.Players.LocalPlayer local HatPackOne = 223106881 local HatPackTwo = 2 local Auth = require(game.Workspace.Folder.CheckPass) function Auth1(Player) return game:GetService("GamePassService"):PlayerHasPass(Player,HatPackOne) end function Auth2(Player) return game:GetService("GamePassService"):PlayerHasPass(Player,HatPackTwo) end script.Parent.MouseButton1Click:connect(function() if Auth.Auth1(P) then print("Player has the pack! Omg! Im so rich!") end end)
Yep! You can use RemoteFunctions!
In a regular script in Workspace, do this:
local Auth = require(workspace.Folder.CheckPass) local checkPass = Instance.new("RemoteFunction",workspace) checkPass.Name = "checkPass" function checkPass.OnServerInvoke(player,hatpack) if hatpack == "One" then return Auth.hasPackOne(player) elseif hatpack=="Two" then return Auth.hasPackTwo(player) end end
Change the module script to this:
local module = {} local pass = game:GetService("GamePassService") local HatPackOne = 223106881 local HatPackTwo = 2 function module.Authin(player,Pack) return pass:PlayerHasPass(player,Pack) end function module.hasPackOne(player) return module.Authin(player,HatPackOne) end function module.hasPackTwo(player) return module.Authin(player,HatPackTwo) end return module
And change the local-script to this:
local P = game.Players.LocalPlayer local hasPackOne = workspace:WaitForChild("checkPass"):InvokeServer("One") local hasPackTwo= workspace:WaitForChild("checkPass"):InvokeServer("Two") script.Parent.MouseButton1Click:connect(function() if hasPackOne then print("Player has the pack! Omg! Im so rich!") end end)
Although the code above is untested; it basically uses remotefunctions to communicate with the server and client.