Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

i cannot buy tools from my tool shop gui?

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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.

0
I recommend using remote events for this kind of stuff boomthefist 6 — 2y
0
because by not using a remote event the tool will only equip and show locally boomthefist 6 — 2y
Ad

Answer this question