Checking if a user has gamepass

wait what. Somehow i retested it and its working now lol

1 Like

also I know this is really messy but its not working again.

local rs = game:GetService('ReplicatedStorage')
local sizeEvent = rs:WaitForChild('SizeEvent')

local GAMEPASS_ID = 25131282
local MarketPlaceService = game:GetService("MarketplaceService")


game.Players.PlayerAdded:Connect(function(player)
	
	if MarketPlaceService:UserOwnsGamePassAsync(GAMEPASS_ID) then
		local rs = game:GetService('ReplicatedStorage')
		local sizeEvent = rs:WaitForChild('SizeEvent')
		sizeEvent.OnServerEvent:Connect(function(plr, size)
			game.Workspace.Click:Play()
			plr:WaitForChild("leaderstats"):WaitForChild("Size").Value = plr:WaitForChild("leaderstats"):WaitForChild("Size").Value + 2
			game.Workspace.CurrentCamera.FieldOfView = game.Workspace.CurrentCamera.FieldOfView + .5
			plr.Character.Humanoid.HeadScale.Value = plr.Character.Humanoid.HeadScale.Value + .1
			plr.Character.Humanoid.BodyDepthScale.Value = plr.Character.Humanoid.BodyDepthScale.Value + .1
			plr.Character.Humanoid.BodyWidthScale.Value = plr.Character.Humanoid.BodyWidthScale.Value + .1
			plr.Character.Humanoid.BodyHeightScale.Value = plr.Character.Humanoid.BodyHeightScale.Value + .1
		end)
		else
			local rs = game:GetService('ReplicatedStorage')
			local sizeEvent = rs:WaitForChild('SizeEvent')
		sizeEvent.OnServerEvent:Connect(function(plr, size)
			game.Workspace.Click:Play()
			plr:WaitForChild("leaderstats"):WaitForChild("Size").Value = plr:WaitForChild("leaderstats"):WaitForChild("Size").Value + 1
			game.Workspace.CurrentCamera.FieldOfView = game.Workspace.CurrentCamera.FieldOfView + .25
			plr.Character.Humanoid.HeadScale.Value = plr.Character.Humanoid.HeadScale.Value + .05
			plr.Character.Humanoid.BodyDepthScale.Value = plr.Character.Humanoid.BodyDepthScale.Value + .05
			plr.Character.Humanoid.BodyWidthScale.Value = plr.Character.Humanoid.BodyWidthScale.Value + .05
			plr.Character.Humanoid.BodyHeightScale.Value = plr.Character.Humanoid.BodyHeightScale.Value + .05
	end)
end

A good way to debug code by yourself is to add print statements for each event/if statement to see where the code errors/stops. If you do not receive a studio error, it means your code is functioning properly (yet it might not function the way you want it to)

Can’t believe I forgot this, but you have to pass a UserId to the UserOwnsGamepassAsync, for example:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 0 -- Put gamepass ID here

Players.PlayerAdded:Connect(function(plr)
	if MarketplaceService:UserOwnsGamePassAsync(plr.UserId,gamepassId)
		-- Run gamepass stuff
	else
		-- Run normal stuff
	end
end)
1 Like

so that why it didnt work probally lol

Yes, probably. Try testing it out though, and report back if it has issues.

I tried it, I am not getting any errors in output.

local rs = game:GetService('ReplicatedStorage')
local sizeEvent = rs:WaitForChild('SizeEvent')

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 25131282 -- Put gamepass ID here

Players.PlayerAdded:Connect(function(plr)
	if MarketplaceService:UserOwnsGamePassAsync(plr.UserId,gamepassId)
		sizeEvent.OnServerEvent:Connect(function(plr, size)

			game.Workspace.Click:Play()
			plr:WaitForChild("leaderstats"):WaitForChild("Size").Value = plr:WaitForChild("leaderstats"):WaitForChild("Size").Value + 2
			game.Workspace.CurrentCamera.FieldOfView = game.Workspace.CurrentCamera.FieldOfView + .5
			plr.Character.Humanoid.HeadScale.Value = plr.Character.Humanoid.HeadScale.Value + .1
			plr.Character.Humanoid.BodyDepthScale.Value = plr.Character.Humanoid.BodyDepthScale.Value + .1
			plr.Character.Humanoid.BodyWidthScale.Value = plr.Character.Humanoid.BodyWidthScale.Value + .1
			plr.Character.Humanoid.BodyHeightScale.Value = plr.Character.Humanoid.BodyHeightScale.Value + .1
		end)
		else
	sizeEvent.OnServerEvent:Connect(function(plr, size)

		game.Workspace.Click:Play()
		plr:WaitForChild("leaderstats"):WaitForChild("Size").Value = plr:WaitForChild("leaderstats"):WaitForChild("Size").Value + 1
		game.Workspace.CurrentCamera.FieldOfView = game.Workspace.CurrentCamera.FieldOfView + .25
		plr.Character.Humanoid.HeadScale.Value = plr.Character.Humanoid.HeadScale.Value + .05
		plr.Character.Humanoid.BodyDepthScale.Value = plr.Character.Humanoid.BodyDepthScale.Value + .05
		plr.Character.Humanoid.BodyWidthScale.Value = plr.Character.Humanoid.BodyWidthScale.Value + .05
		plr.Character.Humanoid.BodyHeightScale.Value = plr.Character.Humanoid.BodyHeightScale.Value + .05
	end)
end
end)

plr:WaitForChild(“leaderstats”):WaitForChild(“Size”).Value = plr:WaitForChild(“leaderstats”):WaitForChild(“Size”).Value + 2

Correct Form Is plr:WaitForChild(“leaderstats”).Size.Value