I have the game set up like this
game
-Workspace
--NPC
---Head
----Dialog
-----Script
-----Regeneration
-----Restoration
-ServerStorage
--Weapons
---Regeneration Potion
---Restoration Potion
It works fine when testing it in studio, but when I go to test it in an actual game with my friend, the item isn't given to me and the dialog says it's default "error", then the dialog doesn't pop back up. What's the problem i'm missing?
local dialog = script.Parent
local weaponstore = game.ServerStorage.Weapons
dialog.DialogChoiceSelected:connect(function(player, choice)
local stats = player:FindFirstChild('leaderstats')
if not stats then return end
local gold = stats:FindFirstChild('Gold')
if not gold then return end
if choice == dialog.Restoration then
if gold.Value >= 100 then
weaponstore["Restoration Potion"]:Clone().Parent = player.Backpack
gold.Value = gold.Value - 100
dialog.Restoration.ResponseDialog = "Good choice, my friend. Use it wisely."
else
dialog.Restoration.ResponseDialog = "Seems you haven't enough money! Alas, wealth is not infinite my friend."
end
elseif choice == dialog.Regeneration then
if gold.Value >= 100 then
weaponstore["Regeneration Potion"]:Clone().Parent = player.Backpack
gold.Value = gold.Value - 100
dialog.Regeneration.ResponseDialog = "Ah, a very nice potion. Enjoy it."
else
dialog.Regeneration.ResponseDialog = "You need more gold if you want my brew."
end
end
end)
