Hello everyone,
I've recently began working on my own game which has resulted in multiple errors. I'm used to working with C# and since Roblox used Lua. Well yea... I've looked through multiple forums, tutorials and a little bit on this website for a solution to my problem. I'm trying to make a player change teams when pressing a button on a gui whilst checking the gamepass. As gamepassservice requires the script to be server sided I can't use a localscript. In the Roblox studio this code works but when I go in-game and I press the gui it doesn't.
This is my script:
local gamepassID = ******
script.Parent.MouseButton1Click:connect(function (playerWhoClicked)
local player = game.Players.LocalPlayer
local gps = game:GetService("GamePassService")
local playerHasPass = gps:PlayerHasPass(player, gamepassID)
if playerHasPass then
player.Team = game.Teams.HATO
else
gps:PromptPurchase(player, gamepassID)
end
end)
Kind regards,
SamDeNormaleAap
