local player = game.Players.LocalPlayer
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,162872866) ------ Your Gamepass ID here
if ownsGamepass then
local sword = game:GetService("ReplicatedStorage"):WaitForChild("Slipper"):Clone() -------- Change "ClassicSword" to your tool's name
sword.Parent = player.Backpack
end
This script works but the tool doesn’t work. The tools do not function with this script. Any recommended fix?
please if you are replicating something never do it on a local script unless of course you need to. The problem is your doing this on a local script so instead move it to a server script and try:
game.Players.PlayerAdded:Connect(function(player)
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,162872866) ------ Your Gamepass ID here
if ownsGamepass then
local sword = game:GetService("ReplicatedStorage"):WaitForChild("Slipper"):Clone() -------Change "ClassicSword" to your tool's name
sword.Parent = player.Backpack
end
end)
This is the solution, make sure to put in Server script:
-- server:
local function shouldGetItem(player)
local ran, result = pcall(function()
game.MarketplaceService:UserOwnsGamePassAsync(player.UserId, 162872866)
end)
return ran and result or false
end
game.Players.PlayerAdded:Connect(function(player)
if shouldGetItem(player) then
player.CharacterAdded:Connect(function()
game.ReplicatedStorage.Slipper:Clone().Parent = player.Backpack
end)
end
end)
Like @hya123456h said Never Ever EVER replicate an item from the client.
Any server scripts in that item will not work, because it will only run on the client