I went back to developing a game after a few months to find scripts broke. I fixed some by making them localscripts, but one did not work. It has no visible errors, and changes to paths do nothing. This script is unchanged from when it worked, and now no parts of it work.
--// Script for SwordMerchant or NPC shop NPC head \\--
script.Parent.DialogChoiceSelected:connect(function(player, choice)
if choice == script.Parent.DialogChoice.BronzeSword.Yes then
if player.leaderstats.Gold.Value >= 200 then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 200
game.ReplicatedStorage.BronzeSword:Clone().Parent = player.Backpack
game.ReplicatedStorage.BronzeSword:Clone().Parent = player.StarterGear
local gui = game.ReplicatedStorage.Success:Clone()
gui.Parent = player.PlayerGui
gui.Script.Disabled = false
else
local gui = game.ReplicatedStorage.Decline:Clone()
gui.Parent = player.PlayerGui
gui.Script.Disabled = false
end
elseif choice == script.Parent.DialogChoice.GoldenHeart.Yes then
if player.leaderstats.Gold.Value >= 1000000 then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 1000000
game.ReplicatedStorage.GoldenHeartSword:Clone().Parent = player.Backpack
game.ReplicatedStorage.GoldenHeartSword:Clone().Parent = player.StarterGear
local gui = game.ReplicatedStorage.Success:Clone()
gui.Parent = player.PlayerGui
gui.Script.Disabled = false
else
local gui = game.ReplicatedStorage.Decline:Clone()
gui.Parent = player.PlayerGui
gui.Script.Disabled = false
end
elseif choice == script.Parent.DialogChoice.IronSword.Yes then
if player.leaderstats.Gold.Value >= 400 then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 400
game.ReplicatedStorage.IronSword:Clone().Parent = player.Backpack
game.ReplicatedStorage.IronSword:Clone().Parent = player.StarterGear
local gui = game.ReplicatedStorage.Success:Clone()
gui.Parent = player.PlayerGui
gui.Script.Disabled = false
else
local gui = game.ReplicatedStorage.Decline:Clone()
gui.Parent = player.PlayerGui
gui.Script.Disabled = false
end
elseif choice == script.Parent.DialogChoice.SteelSword.Yes then
if player.leaderstats.Gold.Value >= 500 then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 500
game.ReplicatedStorage.SteelSword:Clone().Parent = player.Backpack
game.ReplicatedStorage.SteelSword:Clone().Parent = player.StarterGear
local gui = game.ReplicatedStorage.Success:Clone()
gui.Parent = player.PlayerGui
gui.Script.Disabled = false
else
local gui = game.ReplicatedStorage.Decline:Clone()
gui.Parent = player.PlayerGui
gui.Parent.Disabled = false
end
end
end)

7 comments
I used the code provided, and it still does nothing. The print doesn't even go through.
Are you using a LocalScript or a Server Script?, and where is the script located? (script.Parent)
I tried both, if I use a localscript though, sometimes the Dialog will not appear above the NPC, only the choices.
ok, well since the print is not reading, then the function isn't giving a value for player, you need to use a local script anyway due to the nature of PlayerGui, so try adding a line above to define the player as "local player = game.Players.LocalPlayer" and see if you get the output then. Make sure that the script parent is the dialog itself
No luck with that change.
oh, since you have to use a LocalScript, the LocalScript must be placed into the StarterGui. However, by doing this, you have to edit the script.Parent to be the exact location of the dialog
Ok, so now it prints the player's name. Directly after this, it reads this error: "DialogChoice is not a valid member of PlayerGui" Everytime a choose an option, otherwise, it works now. Edit: It's because I didn't change paths on all parts of the script