Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make the text gui change dialogue when the user has a badge?

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.

9 comments

0

PLEASE PLEASE PLEASE use a code block

0

If you want the ID of the player on the client, use game.Players.LocalPlayer.UserId

0

Oh I forgot to use the code block, sorry for that.

0

UserHasBadge should only be used in a localscript. This would explain how it behaves. Info http://wiki.roblox.com/index.php?title=API:Class/BadgeService/UserHasBadge

0

It still doesn't work either way, i've tried that previously but it hasn't worked with a server script and local.

0

Where are you putting the serverscript?

0

The script is located in a textbox in a gui in the replicatedstorage, but it doesn't work.

0

You cannot run scripts inside of GUIs, only localscripts. serverscripts only work in workspace and serverscriptstorage

0

i've tried putting it in the workspace, but it changes for everybody.

1 answer

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!

1 comment

0

It didn't work, unfortunately.

This discussion is preserved as it was. New answers, comments, and votes are closed.