Attempting to give premium users a tool

Hello. I am hug125215 and I am trying to give to users that own the Roblox premium users a tool called LoungeAccess.
But, when I test the game, I don’t find any error in the F9 logs related to the script but the tool is not given to me, even if I own the Roblox premium subscription.
I used this code which is available on the developer hub, here: Premium Payouts and added more code to give a tool to the player,but it is not working.

More details and information in the pictures below:

Script:
Screenshot_2221

Location of the localscript:
Screenshot_2220

Have a good day and I hope that you will be able to help me!

4 Likes

First of all, you cannot access the ServerStorage or any of the server-sided containers with a LocalScript. This has to be done with a server-sided Script.

Second, you cannot add something to the player backpack before the player’s character has spawned or “loaded” into the game.

Here’s an example of how you would approach this assuming the script is in ServerScriptService:

    game.Players.PlayerAdded:Connect(function(Player)
        Player.CharacterAdded:Connect(function()
            if Player.MembershipType == Enum.MembershipType.Premium then
               game.ServerStorage.LoungeAccess:Clone().Parent = Player.Backpack 
            end
        end)
    end)
3 Likes

You cant use a LocalScript for this type of thing instead you could use a simple script that is in SSS, and you just check if the player has premium.

game.Players.PlayerAdded:connect(function(player)
local SS = game.ServerStorage

if player.MembershipType == Enum.MembershipType.Premium then
SS.TOOL:Clone().Parent = player.Backpack
SS.TOOL:Clone().Parent = player.StarterGear
end

end)

TOOL being the tool/gear you wish to give the premium user who has joined the game.

6 Likes

It won’t work for a number of reasons:

  1. It’s local and done on the client

  2. ReplicatedFirst is meant for things like custom loading screens


A fix would be to convert it to a Script and place it inside ServerScriptService.

3 Likes

Thank you alot for helping me! Your script worked!

2 Likes