I have a script that is suppose to change dialogue when the player has a certain badge but this isn't working. The script is located in a textbox in a gui in the replicatedstorage, but it doesn't work.
badge = game:GetService("BadgeService") if badge:UserHasBadge(script.Parent.Parent.Parent.Parent.Parent.userId,981497474) then script.Parent.Text = "Thanks for helping me out!" script.Parent.Parent.Button1.Visible = false script.Parent.Parent.Button2.Text = "Close Dialog" end
It works in studio, but does not work in-game.
I also feel like the issue is because it cannot properly locate the player. In studio, it looks for the player through the playergui in the user's stats or whatever, but i'm not too sure about an actual server.
Thanks.
This should work for you:
local BadgeService = game:GetService("BadgeService") local BadgeId = 981497474 local player = game.Players.LocalPlayer if BadgeService:UserHasBadge(player.UserId, BadgeId) then script.Parent.Text = "You have the badge" end
Please accept my answer if this helped!