Here's the error:
Players.VipDanT.PlayerGui.Game.Badges.MainBadges.Script:4: attempt to index nil with 'UserHasBadgeAsync'
Here's the code:
local player = game.Players.LocalPlayer local gmt = script.Parent["Game Monster"] if player:UserHasBadgeAsync(function(text) gmt.Text = "Joshua - He doesn't like visitors staying too long" end) then end
I'm trying to make it so that if you own the badge, the text changes to gmt.text, however it is not working. anyone know why?
Um... I'm not sure what you wrote there but, the function player:UserHasBadgeAsync
requires 2 parameters, the player's UserId, and the BadgeId
So you could do something like this:
local player = game.Players.LocalPlayer local gmt = script.Parent["Game Monster"] local BadgeS = game:GetService("BadgeService") local BadgeID = 2124475816 if BadgeS:UserHasBadgeAsync(player.UserId, BadgeID) then gmt.Text = "Joshua - He doesn't like visitors staying too long" end
This script will only work on a LocalScript btw, I know you said it was a normal script, yet you used LocalPlayer
, which only works on LocalScripts lol
Of course that also means the edited text will not replicate in the server, and only change for the client.