The code is not working as intended

Do you still receive no errors? also I have a few questions

Script.parent is the item
how are you able to do this

script.Parent.MouseButton1Click:Connect(function()

what instance is it

it is a image button and there are 0 errors

You index info here

But, you index sale in the script :face_with_monocle: Is that correct? I wanted to see when sale remotefunction was Invoked thats why* im curious.

there are 2 remote functions, info and sale and yes it is correct ( i debugged it, and it worked)

sorry for the late reply

local rep = game:GetService("ReplicatedStorage")
local itemsel = script.Parent.Parent.selecter

local cantbuy = script.Parent.Parent.cant_buy
local status = script.Parent.Parent.status
local success

script.Parent.MouseButton1Click:Connect(function()
	success = false
	if itemsel.Value ~= nil then
		success = rep.Remotes.sale:InvokeServer(itemsel.Value)
	end
	if not success  then
		status.Text = "CANT BUY!"
		wait(0.00001)
		cantbuy.Visible = true
		script.Parent.Visible = false
	else
		status.Text = "CANT BUY!"
		wait(0.00001)
		cantbuy.Visible = true
		script.Parent.Visible = false
		script.Parent.Visible = true
		status.Text = "Equipped"
		wait(0.0001)
	end
end)

im gonna sleep guys so pls help me thank you! :slight_smile:

Copy and paste every script in the game here. I might do God’s bidding for you.

i dont understand ? pls tell what u saying

local rep = game:GetService("ReplicatedStorage")
local items = game:GetService("ServerStorage"):WaitForChild("Tools")

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder")
	stats.Name ="leaderstats"
	stats.Parent = player
	
	local Strength = Instance.new("NumberValue")
	Strength.Name ="Strength"
	Strength.Parent = stats
	
	local Coins = Instance.new("NumberValue")
	Coins.Name ="Coins"
	Coins.Parent = stats
	Coins.Value =50

	
	
	local gems = Instance.new("NumberValue", stats)
	gems.Name = "Gems"
	
	local storage = Instance.new("NumberValue")
	storage.Value = 10
	storage.Name = "Storage"
	storage.Parent = player
	
	local Class = Instance.new("StringValue")
	Class.Name = "Class"
	Class.Parent = stats
	
	local Equipped = Instance.new("StringValue", player)
	Equipped.Name = "Equipped"
	
	local items = Instance.new("Folder", player)
	items.Name = "OwnedItems"
end)
rep.Remotes.info.OnServerInvoke = function(player , item)
	return items[item].Cost.Value
end
game:GetService("ReplicatedStorage").Remotes.sale.OnServerInvoke = function(player , item)
	local playergui = player.PlayerGui
	print(player.Name.."Invoked server")
	price = items[item].Cost.Value
	if player.leaderstats.Coins.Value < price then
		playergui.tools_gui.tools_frame.canbuy.ImageTransparency = 1
		print("aa") game.StarterGui.tools_gui.tools_frame.cant_buy.ImageTransparency = 0 
		print("bb") 
		playergui.tools_gui.tools_frame.status.Text = "CANT BUY!" 
		print("Cc")
		
	elseif player.leaderstats.Coins.Value >= price then 
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - price
			playergui.tools_gui.tools_frame.canbuy.ImageTransparency = 0
			print("a")
			playergui.tools_gui.tools_frame.cant_buy.ImageTransparency =1
			print("b")
			playergui.tools_gui.tools_frame.status.Text = "BUY!"
		print("c")
		local gear = items[item]:Clone()
		gear.Parent = game.ServerStorage.OwnedItems

		local gear = items[item]:Clone()
		gear.Parent = player.Backpack
		return true
	end
end
local module = {}
for i,tool in pairs(game.StarterPack:GetChildren()) do
	
	dirtovalk = game.StarterPack["Valkyrie of dirt"]
	module.dirt = {"Valkyrie of Dirt" , 0 , dirtovalk.TextureId}
	
end
for i,tool in pairs(game.ServerStorage:GetChildren()) do
	purple = game.ServerStorage.Tools["Purple Valkyrie"]
	module.purple = {"Purple Valkyrie", 50, purple.TextureId}
end

return module

local rep = game:GetService("ReplicatedStorage")
local itemsel = script.Parent.Parent.selecter

local cantbuy = script.Parent.Parent.cant_buy
local status = script.Parent.Parent.status
local success

script.Parent.MouseButton1Click:Connect(function()
	success = false
	if itemsel.Value ~= nil then
		success = rep.Remotes.sale:InvokeServer(itemsel.Value)
	end
	if not success  then
		status.Text = "CANT BUY!"
		wait(0.00001)
		cantbuy.Visible = true
		script.Parent.Visible = false
	else
		status.Text = "CANT BUY!"
		wait(0.00001)
		cantbuy.Visible = true
		script.Parent.Visible = false
		script.Parent.Visible = true
		status.Text = "Equipped"
		wait(0.0001)
	end
end)
local player = game:GetService("Players").LocalPlayer

game.ReplicatedStorage.Remotes.sale.OnClientInvoke = function(item)
	
	local price = game.ServerStorage.Tools[item].Cost.Value
	if player.leaderstats.Coins.Value < price then
		game.StarterGui.tools_gui.tools_frame.canbuy.ImageTransparency = 1
		print("aa") game.StarterGui.tools_gui.tools_frame.cant_buy.ImageTransparency = 0 
		print("bb") 
		game.StarterGui.tools_gui.tools_frame.status.Text = "CANT BUY!" 
		print("Cc")

	elseif player.leaderstats.Coins.Value >= price then 
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - price
		game.StarterGui.tools_gui.tools_frame.canbuy.ImageTransparency = 0
		print("a")
		game.StarterGui.tools_gui.tools_frame.cant_buy.ImageTransparency =1
		print("b")
		game.StarterGui.tools_gui.tools_frame.status.Text = "BUY!"
		print("c")
		return true
	end
end
local reps = game:GetService("ReplicatedStorage")

local item = script.Parent.Parent.Parent:WaitForChild("selecter")
local img = script.Parent.Parent.Parent:WaitForChild("tool_img")
local name = script.Parent.Parent.Parent:WaitForChild("name")

script.Parent.MouseButton1Click:Connect(function()
	
	local price = reps.Remotes.info:InvokeServer(script.Parent.Name)
	
	if price ~= nil then
		name.Text = script.Parent.Name
		img.Image = script.Parent.A.Image
		item.Value = script.Parent.Name
		script.Parent.Parent.Parent.price.Text = price
		
	end
end)

thats it
@Limited_Unique

Blockquote

help please :frowning: i need this effect to work in my game

the video

sorry for the poor quality (i I hope u understand what is going on

Sorry I stopped replying after you said I assumed you solved it.

To debug. Can you add some prints before you run code inside that Gui button?
It looks as if there’s no event connected.

hey i got an error here is the error

ServerScriptService.leaderstats:44: invalid argument #2 (string expected, got nil)

local rep = game:GetService("ReplicatedStorage")
local items = game:GetService("ServerStorage"):WaitForChild("Tools")

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder")
	stats.Name ="leaderstats"
	stats.Parent = player
	
	local Strength = Instance.new("NumberValue")
	Strength.Name ="Strength"
	Strength.Parent = stats
	
	local Coins = Instance.new("NumberValue")
	Coins.Name ="Coins"
	Coins.Parent = stats
	Coins.Value =50

	
	
	local gems = Instance.new("NumberValue", stats)
	gems.Name = "Gems"
	
	local storage = Instance.new("NumberValue")
	storage.Value = 10
	storage.Name = "Storage"
	storage.Parent = player
	
	local Class = Instance.new("StringValue")
	Class.Name = "Class"
	Class.Parent = stats
	
	local Equipped = Instance.new("StringValue", player)
	Equipped.Name = "Equipped"
	
	local items = Instance.new("Folder", player)
	items.Name = "OwnedItems"
end)
rep.Remotes.info.OnServerInvoke = function(player , item)
	return items[item].Cost.Value
end
game:GetService("ReplicatedStorage").Remotes.sale.OnServerInvoke = function(player , item)
	local playergui = player.PlayerGui
	print(player.Name.."Invoked server")
	price = items[item].Cost.Value
	if player.leaderstats.Coins.Value < price then
		playergui.tools_gui.tools_frame.canbuy.ImageTransparency = 1
		print("aa") game.StarterGui.tools_gui.tools_frame.cant_buy.ImageTransparency = 0 
		print("bb") 
		playergui.tools_gui.tools_frame.status.Text = "CANT BUY!" 
		print("Cc")
		return false
		
	elseif player.leaderstats.Coins.Value >= price then 
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - price
		playergui.tools_gui.tools_frame.canbuy.ImageTransparency = 0
		print("a")
		playergui.tools_gui.tools_frame.cant_buy.ImageTransparency =1
		print("b")
		playergui.tools_gui.tools_frame.status.Text = "BUY!"
		print("c")
		local gear = items[item]:Clone()
		gear.Parent = game.ServerStorage.OwnedItems

		local gear = items[item]:Clone()
		gear.Parent = player.Backpack
		return true
		end
	end

Which line is line 44? I don’t have the patience to count to 44 sorry.

this :

price = items[item].Cost.Value

never mind i fixed the error but the bug still is there

I can help with this, with a more simple script, but it would really help if you sent the explorer, so it would be easier for me to make a script you understand.

are these screenshots enough? @D4nisback3lbz