I want to make a clicking gui, if you have a gamepass you get 5 clicks.
local button = script.Parent
local event = game.ReplicatedStorage.ClickEvent
local MarketPlaceService = game:GetService("MarketplaceService")
local GamePassID = 14531115
local player = game:GetService("Players")
button.MouseButton1Click:Connect(function(player)
event:FireServer()
print("yay working")
leaderstats.Clicks.Value = leaderstats.Clicks.Value + 1
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassID) then
leaderstats.Clicks.Value = leaderstats.Clicks.Value + 5
end
end)
It looks like you’re handling this on the client, I believe the player object will not be passed as argument if it’s client because you can simply do game.Players.LocalPlayer, but if you change it to a server script it should work
local button = script.Parent
local event = game.ReplicatedStorage.ClickEvent
local MarketPlaceService = game:GetService("MarketplaceService")
local GamePassID = 14531115
local player = game:GetService("Players").LocalPlayer
button.MouseButton1Click:Connect(function()
event:FireServer()
print("yay working")
player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value + 1
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassID) then
player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value + 5
end
end)
This doesn’t have anything to do with the issue but this can be rewritten as leaderstats.Clicks.Value += 1. It works just fine you’re way, I just think this looks more organized.