Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why if player has gamepass he can't receive item from lighting?

Hello everyone, I have problem with probably game pass service or just with Clone(). When player will buy game pass should get items from ReplicatedStorage.PassItems, but i don't know why don't work ;/ If someone can solve it.

Here is script:

pcall(function()
	game.Players.PlayerAdded:connect(function(player)
		if game.GamePassService:PlayerHasPass(player,298834435) then
			local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
			cashmoney.Value = cashmoney.Value + 5000
			player.CharacterAdded:connect(function(char)
				if char:WaitForChild("Humanoid") then
					char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
					char.Humanoid.Health = char.Humanoid.Health + 25
					char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + 8
					game.ReplicatedStorage.PassItems.SpeedPotion:Clone().Parent = player.Backpack
				end
			end)
			local msg = Instance.new("Hint",workspace)
			msg.Text = player.Name.." joined the game with Ultra V.I.P."
			wait(2)
			msg:Destroy()
		elseif game.GamePassService:PlayerHasPass(player,298833834) then
			local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
			cashmoney.Value = cashmoney.Value + 200
			local msg = Instance.new("Hint",workspace)
			msg.Text = player.Name.." joined the game as a V.I.P."
			wait(2)
			msg:Destroy()
		elseif game.GamePassService:PlayerHasPass(player,303658886) then
			player.CharacterAdded:connect(function(char)
				if char:WaitForChild("Humanoid") then
					game.ReplicatedStorage.PassItems.Boombox:Clone().Parent = player.Backpack
				end
			end)
		end
	end)
end)

3 comments

0

I would say it is most likely the fact GamePassService is not a valid member of data model and you would have to use GetService to access the service. Also, for testing purposes I would recommend removing pcall as it will hide errors as well. BlueTaslem will even argue, if your code is good enough you should not even be needing a protection call.

0

I don't know why people downgrading it 0_0 probably kids got 25+ Reputation and giving it to everyone ;s and yeah i thought about GetService, so i'll try it.

0

I changed it and still can't receive items ;/

2 answers

In Line 11 you put :Clone().Paren = player.Backpack instead of :Clone().Parent = player.Backpack.

1 comment

0

No, that got cut off somehow in the formatting process. If you look at the raw text, the full word is present.

try setting line 03 to:

game:GetService("MarketplaceService"):PlayerOwnsAsset(player,id)

change the id to the id(too lazy to look at the script)

also, i would recommend not using Lighting and switching to a different storage

tell me if this works

2 comments

0

anyone mind telling me why they are downvoting this?

0

I'm using ReplicatedStorage, so i don't where you read Lighting... And it's wrong, becouse i need to use GamePassService ;s

This discussion is preserved as it was. New answers, comments, and votes are closed.