So i’ve made a badge and I was wondering on how to make something appear only for the client and not for other players. Im really unsure what to do and don’t want to go through the hard way of doing this.
1 Like
use BadgeService:UserOwnsBadgeAsync(player,badgeid)
for example:
local badgeService = game:GetService("BadgeService")
local badgeId = --badge id here
local plr = game:GetService("Players").LocalPlayer
if badgeService:UserOwnsBadgeAsync(plr, badgeId) then
script.Parent.TextButton.Visible = true
end
as far as i know, UserOwnsBadgeAsync() return a “true” if the user owns the badge, and a “false” if they dont.
Hope i helped!
1 Like
I attempted this on a LocalScript and it seems to do nothing.
Use a server-script.
game:GetService("Players").PlayerAdded:Connect(function(Player)
if game:GetService("BadgeService"):UserHasBadgeAsync(Player.UserId, ID) then
--Client Event
end
end)
2 Likes
Btw, you probably meant “UserHasBadgeAsync”?
You can use UserHasBadgeAsync in a localscript and you can use it with the localplayer’s userId to check if he contains a certain badge!
I quickly made a button that uses that to open a ‘Door’ in workspace for me, it only works if I have the badge though.
local Door = game.Workspace.Part
local badgeService = game:GetService("BadgeService")
local badgeId = 2141630107
script.Parent.MouseButton1Down:Connect(function() -- When the button is clicked
if badgeService:UserHasBadgeAsync(game.Players.LocalPlayer.UserId, badgeId) then -- If localplayer has the badge then
Door.CanCollide = false
Door.Transparency = 0.5
end
end)
-- Keep in mind this is just an example, this is a localscript inside a TextButton!
3 Likes
I got it working! It doesn’t seem to work in Studio but works in game!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.