Give A Item To Premium Players

Hello. I’m Making A Rocket Fighting Game. And I Want Go Give Premium Players A Sword.
Do You Know How To Do It?

4 Likes

The API knows all

Check if a player is subscribed to Roblox Premium,

then give the player whatever tools you want by cloning them to the player’s Backpack

6 Likes

What Does Cloning Mean?
I Am Very Low Experienced At Scripting.

1 Like

a second on a browser,

image

https://developer.roblox.com/en-us/api-reference/function/Instance/Clone

To clone an object , just do this:

 local clone = Instance:Clone()

All of the cloned instance’s properties are exactly copied (except the Parent property which is nil)

2 Likes

Try Edit My Script!

  local MarketplaceService = game:GetService("MarketplaceService")
    local Players = game:GetService("Players")
    local sword = game.      -- Put Your Sword Path To Whereever your sword is
    local showprompt = true

    local function OnTeleporterTouched(otherPart)
    	local player = Players:GetPlayerFromCharacter(otherPart.Parent)
    	if not player then return end
    	
    	-- If User Has Premium
    	if player.MembershipType == Enum.MembershipType.Premium then
    		--- What will Happen!
    		local newsword = sword:Clone()
    		newsword.Parent = player.Backpack
    		
    	else
    			if showprompt == false then return end
    			showprompt = false
    			delay(5, function()
    				showprompt = true
    			end)
    			MarketplaceService:PromptPremiumPurchase(player)
    			warn("Prompted Premium Purchase")
    	end
    	
    end

    teleporter.Touched:Connect(OnTeleporterTouched)
    	MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player)
    		warn("Upsell Modal Closed")
       end)
6 Likes

@HackItsGood, I think @OP can visit the hub and see that code for himself, no need to post it here.


@RobloxbuildermanFan3

That aside, here is a working demonstration :

     local players = game:GetService("Players") 
     local tool = game:GetService("ServerStorage").Tool

     players.PlayerAdded:Connect(function(player)
     if player.MembershipType == Enum.MembershipType.None then return end
 
     local clone = tool:Clone()
     clone.Parent = player.Backpack

     end)      

make sure the tool is called Tool and is in ServerStorage, run this code on the Server (in a server script in ServerScriptService of course) , for multiple tools attempt to iterate through all tools in a generic for loop, in ipairs preferably.

Go everywhere

Players | Documentation - Roblox Creator Hub
Backpack | Documentation - Roblox Creator Hub
Players | Documentation - Roblox Creator Hub
ServerStorage | Documentation - Roblox Creator Hub
ServerScriptService | Documentation - Roblox Creator Hub

7 Likes

I started as you, firstly i learnt everything about building and then i started to learn programming. But it’s not that easy. You should start to learn the basics of them because, in some cases, you will get stuck at the easiest parts. For this i recommend @Alvin_Blox’s tutorials on youtube. You can watch his old series and his brand new 2020 tutorials. Besides him you can try to take free scripted models and learn how do they work, how to make them work and how to edit them in the way you like. Good luck in your journey of programming! :heart:

4 Likes