Oh wait, just noticed you’re using a LocalScript for Proximity. You should use a Script instead.
According to the API page ProximityPrompt, it shouldn’t really matter. Also, they need local script as it should be invisible for only one player
Ok! So is that my problem? I did have a script, but won’t
destory()
remove it for everyone?
Still the issue persists for those who want to use it this way.
BadgeService:AwardBadge only works in a Script. Only the Transparency part has to be in a LocalScript.
Make a Remote to FireClient to a specific player if they pick up the Scroll and set it transparent or destroy.
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