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
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
The script is a localscript (LocalPlayer will only work on a localscript)
The localscript is being run inside
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