Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

i cannot buy tools from my tool shop gui?

I have a tool shop gui and for some reason the script inside of the buy button doesnt work here is the script (it is ss)

local btn = script.Parent


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:FindFirstChild("Noob Sword")

btn.MouseButton1Click:Connect(function(player)
	if player.leaderstats.Currency.Value > 199 then
		
		local tool = Sword:Clone() 
		
		tool.Parent = player.Backpack
		
	end
	
end)

1 answer

Try this

local btn = script.Parent
plr = game.Players.LocalPlayer
btn.MouseButton1Click:Connect(function()
	if game:GetService("ReplicatedStorage"):FindFirstChild("Noob Sword") then
	    if plr.leaderstats.Currency.Value >= 200 then
		plr.leaderstats.Currency.Value = plr.leaderstats.Currency.Value - 200
	        local tool = game:GetService("ReplicatedStorage")["Noob Sword"]:Clone() 
	        tool.Parent = plr.Backpack
	    end
	end
end)

from a local script as gui user input is mostly handled from the client.

2 comments

0

I recommend using remote events for this kind of stuff

0

because by not using a remote event the tool will only equip and show locally

This discussion is preserved as it was. New answers, comments, and votes are closed.