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

Cash Value Buying System Isn't Working. May I Get Some Help?

Asked by 6 years ago
Edited 6 years ago

Script:

script.Parent.MouseButton1Down:Connect(function()
    if game.Players.LocalPlayer.leaderstats.Cash.Value >= 3 then
    local pistol = game.ReplicatedStorage.Pistol:Clone()
    pistol.Parent = game.Players.LocalPlayer.Backpack
    end
    script.Parent.num.Value = script.Parent.num.Value +1
    if script.Parent.num.Value ~= 1 and game.Players.LocalPlayer.leaderstats.Cash.Value < 3 then
    game.Players.LocalPlayer.Backpack.Pistol:Destroy()
            script.Parent.Text = "You already own that!"
            wait(0.5)
            script.Parent.Text = "Pistol"
            end
        end)


So it's like a buying system, if your cash value is more than 3 then you can buy it, also, if you already have one Pistol in your inventory it will not give you another one. But it keeps giving me a pistol even though I already have one in my inventory.

pls help

0
right after the button1down add if num.Value == not 1 then... greatneil80 2647 — 6y
0
Doesn't work gamerbeeze1 -3 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

This here will Give you a Pistol if you have 3 Cash then take it away and clone it it will also make it so it will stay if the player dies. and if the player already has it it wont let them spam it.

local plr = game.Players.LocalPlayer
local replicatedstorage = game:GetService("ReplicatedStorage")

script.Parent.MouseButton1Click:connect(function()
if plr.Backpack:FindFirstChild("Pistol") or plr.StarterGear:FindFirstChild("Pistol") or 
 game.Workspace[plr.Name]:FindFirstChild("Pistol")then
script.Parent.Text = "You Own This Item"
wait(2.5)
script.Parent.Text = "Buy Pistol"
else
if plr.leaderstats.Cash.Value >= 3 then 
    replicatedstorage.Pistol:Clone().Parent = plr.Backpack
    replicatedstorage.Pistol:Clone().Parent = plr.StarterGear
plr.leaderstats.Cash.Value = plr.leaderstats.Points.Value-3
else
    local cashrequired = 3- plr.leaderstats.Cash.Value
    script.Parent.Text = "You Need "..cashrequired.." Cash"
    wait(2.5)
    script.Parent.Text = "Buy Pistol"
end

end     
end)

Also Make sure this is in a LocalScript

Ad

Answer this question