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