I have a script where it gives you a Grenade launcher if you buy a gamepass, The problem is, It only works in Roblox Studio not in the real game. The script is located in Workspace cuz that's the only place it works in for some reason
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(Player) print("PlayerAdded") if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 13440876) then local Replicated = ReplicatedStorage["Grenade Launcher"]:Clone() Replicated.Parent = Player:WaitForChild("Backpack") print("Gave Player Grenade Launcher") print(Player.Name) end end)
The issue with your script, is that you are cloning the tool only to the Backpack. Before I answer your question, next time you ask a question here, please make sure to be more descriptive with your questions, and, use code blocks to show your code. You can do that by pressing the Lua Icon above the description box and paste your code between the 2 lines of ~.
So, with your code, I was unsure what script you had, or where you had it, so, I have got a serverscript in ServerScriptService. This way, we also have access to ServerStorage
, which is a very good way to store Tools and prevent exploits from getting them. What I have done with your script is that I changed the paths from ReplicatedStorage
to ServerStorage
, and also added the tool to StarterGear
. This makes sure that even if you die, you will respawn with it!
local ServerStorage = game:GetService("ServerStorage") local Players = game:GetService("Players") local MarketPlaceService = game:GetService("MarketplaceService") Players.PlayerAdded:Connect(function(Player) if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 13440876) then local Tool = ServerStorage["Grenade Launcher"]:Clone() Tool.Parent = Player.Backpack Tool.Parent = Player.StarterGear print("Gave the item to "..Player.Name) end end)
Keep in Mind: This issue may also be caused by the fact that your place is not published! Please make sure your place is up to date with your updates and make sure everything is published.
I hope this helped you, and if it has, then feel free to Accept the answer, this gives both of us reputation!
first, what script is it a local or server script? if it is a server script then put it in ServerScriptService, also if you have Team Create enabled then check if collabrating editing is on, if yes then you have to commit the changes to the script and publish the game
How about you try this script? (works in Workspace) - you gotta put the grenade launcher inside of the ServerStorage. "PeopleWithFreeGamepass" are the ones that don't have to pay for the grenade launcher :)
local Id = 0 local PeopleWithFreeGamepass = {"person"} local ToolName = {"Tool Here"} local function FindPlayer(Plr) for Num, Pler in pairs(PeopleWithFreeGamepass) do if Pler == Plr then return true end end end game.Players.PlayerAdded:connect(function(Player) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, Id) or FindPlayer(Player.Name) then Player.CharacterAdded:Connect(function(character) for Num, Tool in pairs(ToolName) do if game:GetService("ServerStorage"):FindFirstChild(Tool) then game:GetService("ServerStorage")[Tool]:Clone().Parent = Player.Backpack end end end) for Num, Tool in pairs(ToolName) do if Player.Backpack:FindFirstChild(Tool) == nil then if game:GetService("ServerStorage"):FindFirstChild(Tool) then game:GetService("ServerStorage")[Tool]:Clone().Parent = Player.Backpack end end end end end)