I have a shop with the weapons in replicated storage and pixelgold is the currency under leaderstats in the player. This was working but one day it broke i think Roblox did this with an update. To purchase the weapon the player asks from a shop dialog choice . please tell me what i'm doing wrong.

here is the code also this is my first post so tell me if a posted this wrong

`script.Parent.DialogChoiceSelected:connect(function(player, choice)
	if choice == script.Parent.DialogChoice.Sword.Yes then
		if player.leaderstats.PixelGold.Value >= 30 then
			player.leaderstats.PixelGold.Value = player.leaderstats.PixelGold.Value - 30
			game.ReplicatedStorage.FireSword:Clone().Parent = player.Backpack
			game.ReplicatedStorage.FireSword: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.Gun.Yes then
		 PixelGold = player.Pixelgold.
		if player.leaderstats.PixelGold.Value >= 50 then
			player.leaderstats.PixelGold.Value = player.leaderstats.PixelGold.Value - 50
			game.ReplicatedStorage.Gun:Clone().Parent = player.Backpack
			game.ReplicatedStorage.Gun: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.WeaponCrate.Yes then
		if player.leaderstats.PixelGold.Value >= 50 then
			player.leaderstats.PixelGold.Value = player.leaderstats.PixelGold.Value - 50
			RanddomWeapon = math.random(1,2)
			 if RanddomWeapon == 1 then
			  game.ReplicatedStorage.HeadSword:Clone().Parent = player.Backpack
			  game.ReplicatedStorage.HeadSwpord:Clone().Parent = player.StarterGear
			  local gui = game.ReplicatedStorage.Success:Clone()
			  gui.Parent = player.PlayerGui
			  gui.Script.Disabled = false
			  end
			 if RanddomWeapon == 2 then
			  game.ReplicatedStorage.Gun:Clone().Parent = player.Backpack
			  game.ReplicatedStorage.Gun:Clone().Parent = player.StarterGear
			  local gui = game.ReplicatedStorage.Success:Clone()
			  gui.Parent = player.PlayerGui
			  gui.Script.Disabled = false
			  end
		else
			local gui = game.ReplicatedStorage.Decline:Clone()
			gui.Parent = player.PlayerGui
			gui.Script.Disabled = false
		end
	end
end)

2 comments

0

It's because of the "separation" of client/server. But it's salvageable... https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

0

so what i should do is to make when the player choses the option i should make it cause a remote event to give the player the weapon ( also i made edits but i got this as a free model )