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)
Try doing this:
Wherever the script says Clone().Parent, make the clone a variable THEN change the parent, for example:
Sword:Clone().Parent
becomes
local clone = Sword:Clone() clone.Parent = player.Backpack
Otherwise, im not sure if the function for the dialog is actually calling the player, so use
print(player.Name)
and see if it comes out nil in your output
I've attached a copy of the Revised Code (LocalScript)
--// Script for SwordMerchant or NPC shop NPC head \\-- local player = game.Players.LocalPlayer local location = game.Workspace.NPC.Head.Dialog -- Wherever the Dialog location is location.DialogChoiceSelected:Connect(function(player, choice) print(player.Name) if choice == location.DialogChoice.BronzeSword.Yes then if player.leaderstats.Gold.Value >= 200 then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 200 local BronzeSword1 = game.ReplicatedStorage.BronzeSword:Clone() BronzeSword1.Parent = player.Backpack local BronzeSword2 = game.ReplicatedStorage.BronzeSword:Clone() BronzeSword2.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 == location.DialogChoice.GoldenHeart.Yes then if player.leaderstats.Gold.Value >= 1000000 then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 1000000 local GoldenHeart1 = game.ReplicatedStorage.GoldenHeartSword:Clone() GoldenHeart1.Parent = player.Backpack local GoldenHeart2 = game.ReplicatedStorage.GoldenHeartSword:Clone() GoldenHeart2.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 == location.DialogChoice.IronSword.Yes then if player.leaderstats.Gold.Value >= 400 then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 400 local IronSword1 = game.ReplicatedStorage.IronSword:Clone() IronSword1.Parent = player.Backpack local IronSword2 = game.ReplicatedStorage.IronSword:Clone() IronSword2.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 == location.DialogChoice.SteelSword.Yes then if player.leaderstats.Gold.Value >= 500 then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 500 local SteelSword1 = game.ReplicatedStorage.SteelSword:Clone() SteelSword1.Parent = player.Backpack local SteelSword2 = game.ReplicatedStorage.SteelSword:Clone() SteelSword2.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)
Cloning a object has change it used to be
game.Workspace.Ex:Clone() --or local thing = game.Workspace.Ex:Clone() thing.Parent = game.Workspace.Folder -- now its just local thing = game.Workspace.Ex:Clone() thing.Parent = game.Workspace.Folder