I was looking around but I could only find threads talking about tools, but I want it to add items to an inventory.
This is the datastore. It would add a knife to OwnedKnife.
I was looking around but I could only find threads talking about tools, but I want it to add items to an inventory.
This is the datastore. It would add a knife to OwnedKnife.
Read up on BadgeService. They have functions like BadgeAwarded or OnBadgeAwarded which may help. For the datastore part i am not sure at all.
I know all about the badge stuff already lol im just interested in the datastore
If I’m reading this right, you want to give a player an item based on what they have on their datastore savefile?
They want to give a player an item once they have the badge for it.
For example, if you have a ‘sword’ badge which you’ll achieve when you buy your first sword, they want it so if you rejoin and you ‘own’ the badge you’ll get the sword
I think…
Use this script: (replied to wrong person)
--//Services
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local ServerStorage = game:GetService("ServerStorage")
--//Variables
local BadgeId = 0000000 -- Switch out with your badge ID
local Tool = ServerStorage.Tool -- Switch out with a reference to your tool
--//Functions
Players.PlayerAdded:Connect(function(player)
local success, hasBadge = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, BadgeId)
end)
if not success then
warn("Error while checking if", player, "has badge id", BadgeId, ".")
return
end
if hasBadge then
local Clone = Tool:Clone()
Clone.Parent = player.Backpack
end
end)