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

Make gamepass immediately work after purchase?

The jetpack will only work once the player rejoins. Resetting won't work. Any help is appreciated.

local marketPlaceService = game:GetService('MarketplaceService')
local gamepassId = 9077950 -- Replace with your gamepass Id here

local replicatedStorage = game:GetService('ReplicatedStorage')
local jetpackEvent = Instance.new('RemoteEvent',replicatedStorage)
jetpackEvent.Name = 'JetpackEvent'

game.Players.PlayerAdded:Connect(function(player)
	
	if marketPlaceService:UserOwnsGamePassAsync(player.userId,gamepassId) then
		player.CharacterAdded:Connect(function(character)
		local jetpack = replicatedStorage:WaitForChild('JetpackTool'):Clone()
		jetpack.Parent = player.Backpack
		
		local jetpackAnim = Instance.new('Animation',character)
		jetpackAnim.Name = 'JetpackAnimation'
		jetpackAnim.AnimationId = 'rbxassetid://'..04890594908 --4783206623 R15 animation
		
		local velocity = Instance.new('BodyVelocity',character:WaitForChild('HumanoidRootPart'))
		velocity.Velocity = Vector3.new(0,0,0)
		velocity.MaxForce = Vector3.new(0,0,0)
		
		local gyro = Instance.new('BodyGyro',character:WaitForChild('HumanoidRootPart'))
		gyro.MaxTorque = Vector3.new(0,0,0)
		gyro.CFrame = character:WaitForChild('HumanoidRootPart').CFrame
		gyro.P = 4000
		end)
	else	
		jetpackEvent.OnServerEvent:Connect(function(player,flamer1,flamer2,number)
		if number == 1 then
			flamer1.Enabled = true
			flamer2.Enabled = true
			flamer1.Parent.Parent.Handle.PointLight.Enabled = true
		elseif number == 2 then
			flamer1.Enabled = false
			flamer2.Enabled = false
			flamer1.Parent.Parent.Handle.PointLight.Enabled = false
		elseif number == 3 then
			flamer1.Transparency = NumberSequence.new(0.4)
			flamer2.Transparency = NumberSequence.new(0.4)
			flamer1.Size = NumberSequence.new(0.9)
			flamer2.Size = NumberSequence.new(0.9)
		elseif number == 4 then
			flamer1.Transparency = NumberSequence.new(0)
			flamer2.Transparency = NumberSequence.new(0)
			flamer1.Size = NumberSequence.new(1.5)
			flamer2.Size = NumberSequence.new(1.5)
		elseif number == 5 then
			flamer1.Transparency = NumberSequence.new(0.2)
			flamer2.Transparency = NumberSequence.new(0.2)
			flamer1.Size = NumberSequence.new(1.2)
			flamer2.Size = NumberSequence.new(1.2)
		end
		end)
	end
end)

1 comment

0

How would I integrate the PurchaseFinished event? Game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(player,gamePassId,wasPurchased)

1 answer

Just use player.CharacterAdded:Connect(function(char) instead of only using PlayerAdded so that it also checks whenever the player respawns

2 comments

0

Is there anyway to immediately give the jetpack to the player though?

0

Not that i know of

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