✓ Accepted answer
local cash = game.StarterGui.ScreenGui.cash.cashv
The issue is probably there. Correct me if I am wrong, but you are trying to update the value of a textlabel inside the PlayerGUI. What you've done wrong there is update it inside the StarterGUI, which is what players spawn with when they join the game.
EDIT: Didn't realise you could edit an answer, but oh well here's the instructions for fixing your issues.
Change the name of the value in the TextLabel to ' cashv ' (excluding the quotation marks)
That was one factor in why it didn't work for you.
Ensure there is bread in ServerStorage
Because the bread wasn't in ServerStorage, the script stopped there and didn't continue after that. I managed to avoid this by making the lines with the bread into comments.
Replace the script inside the dialog of the merchant to this:
The only change are is in Line 8 where I moved the local for the variable into the event caller, and where I made it so that it would change for the player rather than inside the StarterGUI.
local merchantdialouge = workspace.Merchant.Head.Dialog:GetChildren()
local Bread = game.ServerStorage.Bread
local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)
if choice == script.Parent.buybread then
local cash = player.PlayerGui.ScreenGui.TextLabel.cashv
if cash.Value >= 5 then
game.ServerStorage.Bread:clone().Parent = player.Backpack
cash.Value = cash.Value - 5
end
end
end)
Finally, delete the LocalScript inside the TextLabel and replace it with a script. Not much difference, but here is the script if you need it:
while true do
wait()
local cash = script.Parent.cashv
local cashDisp = script.Parent
cashDisp.Text = "$"..cash.Value
end
That's all, I'd appreciate it if you accepted the answer. Any issues, feel free to ask! :)
3 comments
Yes, I think that's what I did.
@puppylover133 Revised, please read the answer again.
Thanks, that fixed it! :)