Dialog text not changing when player owns badge

Does anyone know if remote events are required to change dialogue text locally based on owning a badge? I checked that the badgeid is correct and that everything that is referred to in the script exists, however the dialogue is not changing.

local player = game.Players.LocalPlayer
local playerid = player.UserId
local dialog = script.Parent.Dialog
local badgeservice = game.BadgeService
local dialogtxt = dialog.InitialPrompt
local badgeid = 2151651159

if badgeservice:UserHasBadgeAsync(playerid, badgeid) then
	dialogtxt = "What happened..."
end

2 Likes

If you are trying to edit anything locally on a server script, you will have to use a remote event/function connected to a local script.

1 Like

I believe that this issue is NOT caused by the code, but rather the placement of the local script!

Local scripts can only run in certain positions, mainly descendants of the player and / or descendants of the player’s character. It seems that your local script is ultimately a descendant of workspace, and hence won’t run, meaning the code isn’t running and the dialogue is never changed

1 Like

Ensure that

  1. The script is a localscript (LocalPlayer will only work on a localscript)
  2. The localscript is being run inside
    image
  3. The badge id is correct.

Also, I think I notice the issue. Setting dialogtxt to dialog.InitialPrompt, then changing the variable dialogtxt will NOT change dialog.InitialPrompt, but rather just the variable. If you need to change dialog.InitialPrompt, use this:

local player = game.Players.LocalPlayer
local playerid = player.UserId
local dialog = script.Parent.Dialog
local badgeservice = game.BadgeService
local badgeid = 2151651159

if badgeservice:UserHasBadgeAsync(playerid, badgeid) then
	dialog.InitialPrompt = "What happened..."
end
2 Likes

I’m not sure why, but all dialogs have stopped working completely. Does anyone know if this is a Studio bug or an update?

1 Like

Please read here >> Dialog | Documentation - Roblox Creator Hub

1 Like