Hey there. I recently made a donation script, if you donate you'll get a gun. Unfortunately, you have to wait for a new server to actually receive the gun. So, I attempted to make a script that when your purchase is verified, it creates a boolvalue in workspace with that person's name. I got that done, but I'm having trouble making it so that if there's a boolvalue with someone's name, it will give a weapon to that person when they respawn.
This is the code I have so far [making the values is already sorted out]
players = game.Players:GetChildren() function givetools() base = script.Parent:GetChildren() for i, base end
You were more than likely using PlayerHasPass
with the GamePassService
. PlayerHasPass caches results after the first call, which is usually when the player enters the server. If the player purchases anything after than first check, it will still return that previously cached value, which is (false).
PlayerOwnsAsset, when used in LocalScripts, will return live results from the ROBLOX website. Therefore, no matter when he purchases the item, it will return the most recently updated value.
PlayerOwnsAsset (player, assetId)
local Market = game:GetService('MarketplaceService') local Storage = game:GetService('ReplicatedStorage') -- Set storage to the repository containing the weapon local Player = game:GetService('Players').LocalPlayer local Asset = 12345 local function donated(player, assetId) if Market:PlayerOwnsAsset(player, assetId) then for i, weapon in pairs(Storage:GetChildren()) do if weapon.Name == "NameofWeapon" then -- Name weapon to give weapon:clone().Parent = Player.BackPack end end end end donated(Player, Asset)