Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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.

0
PLEASE PLEASE PLEASE use a code block lukeb50 631 — 6y
0
If you want the ID of the player on the client, use game.Players.LocalPlayer.UserId lukeb50 631 — 6y
0
Oh I forgot to use the code block, sorry for that. Skepticlemon 24 — 6y
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 lukeb50 631 — 6y
View all comments (5 more)
0
It still doesn't work either way, i've tried that previously but it hasn't worked with a server script and local. Skepticlemon 24 — 6y
0
Where are you putting the serverscript? lukeb50 631 — 6y
0
The script is located in a textbox in a gui in the replicatedstorage, but it doesn't work. Skepticlemon 24 — 6y
0
You cannot run scripts inside of GUIs, only localscripts. serverscripts only work in workspace and serverscriptstorage lukeb50 631 — 6y
0
i've tried putting it in the workspace, but it changes for everybody. Skepticlemon 24 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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!

0
It didn't work, unfortunately. Skepticlemon 24 — 6y
Ad

Answer this question