But would I check if they owned it in a local script and if that badge was owned set the transparency to 1?
You should always check those things on server.
No idea how to do that? ----------------
Use remote events to get the server to check / award the badge to the player.
Use the local script to hide the part
Hold on, I’ll write real quick
And how do I do that ________________
Ok! Thanks for all you help. ______________
--Serverscript
local BadgeService = game:GetService("BadgeService")
local Badge = 1234567890
--https://developer.roblox.com/en-us/api-reference/class/BadgeService
local function awardBadge(player, badgeId)
local success, badgeInfo = pcall(function()
return BadgeService:GetBadgeInfoAsync(badgeId)
end)
if success then
if badgeInfo.IsEnabled then
local success, result = pcall(function()
return BadgeService:AwardBadge(player.UserId, badgeId)
end)
if not success then
warn("Error while awarding badge:", result)
return false
elseif not result then
warn("Failed to award badge.")
return false
end
return true
end
else
warn("Error while fetching badge info: " .. badgeInfo)
end
return false
end
local Remote = Instance.new("RemoteFunction")
Remote.Name = "ProxBadge"
Remote.Parent = game:GetService("ReplicatedStorage")
Remote.OnServerInvoke = function(Player)
local Character = Player.Character
if not Character then return end
local Root = Character:WaitForChild("HumanoidRootPart")
if not Root then return end
if (Root.Position - workspace.BScroll.Position).Magnitude > 20 then return end
local success, hasBadge = pcall(function()
return BadgeService:UserHasBadgeAsync(Player.UserId, Badge)
end)
if not success then
warn("Error while checking if player has badge!")
return
end
return hasBadge and true or awardBadge(Player, Badge)
end
--Localscript
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("ProxBadge")
workspace.BScroll.ProximityPrompt.Triggered:Connect(function(player)
local Result = Remote:InvokeServer()
if Result == true then
workspace.BScroll:Destroy()
end
end)
----- Server Side
local event = game.ReplicatedStorage.DestroyBScroll-- let's say we got this even in rep storage
local badgeService = game:GetService("BadgeService")
local bbadgeID = 1234567890
game.Workspace.BScroll.ProximityPrompt.Triggered:Connect(function(player)
print("You collected the Builder Scroll")
event:FireClient(player)
if not badgeService:UserHasBadgeAsync(player.UserId, bbadgeID) then
badgeService:AwardBadge(player.UserId, bbadgeID)
end
end)
----- Client, put in StarterPlayerScripts
local event = game.ReplicatedStorage.DestroyBScroll --- the same event we used on server
event.OnClientEvent:Connect(function()
workspace.BScroll:Destroy()
end)
----------
Are these both Scripts or is one LocalScript?
Check commentaries I’ve left in code
Means nothing to me.
Sorry! -______-
Separated them, make a remote event in ReplicatedStorage named as I wrote in the event variables
But are these scripts or local scripts. I don’t understand…
Top one in Script, bottom one is LocalScript. Create a LocalScript in StarterPlayerScripts and put the bottom code into it. Make a Script in BScroll and put the top code into.
Thanks! I’ll test it now! _______________
Do i need a remote event in replicated storage too?
Yep, make a remote event in ReplicatedStorage and name it as it is named in “event” variables - DestroyBScroll
Thanks! Testing it rn ________________