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

How to buy and receive a gear in game?

Asked by 6 years ago

I'm trying to make it so that if you have 30 or more cash, the player can click an image button and receive a gear, however, when I test it out, nothing happens when I try to click on the image button even though I have 50 points. Where am I going wrong? (This is a LocalScript)

local plr = game.Players.LocalPlayer
local replicatedstorage = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:connect(function()
    if plr.leaderstats.Points.Value>=30 then
    replicatedstorage.BloxyCola:Clone().Parent=plr.Backpack
    replicatedstorage.BloxyCola:Clone().Parent=plr.StarterGear
    end


end)

1 answer

Log in to vote
0
Answered by 6 years ago

Hello there! I'm BlackOrange and I will be helping!

Ok, I'm not exactly sure what is wrong with your code BUT! I will give you a code I write right now and you can test it.

Please do note that I came up on spot and errors can occur.

To check if there is any error with your code, you can go to:

View Tab > Output

from there it will give you red text (if there is a problem)

anyway:

local plr = game.Players.LocalPlayer
local BloxyCola = game:GetService('ReplicatedStorage'):WaitForChild('BloxyCola')

script.Parent.MouseButton1Down:Connect(function()
    local CBC = BloxyCola:Clone()
    CBC.Parent = plr.Backpack -- I haven't check if it is .Backpack or .BackPack switch if doesn't work
end)

This should do the trick.

Well, hopefully this helped you some sort of way.

Best of Luck

-- BlackOrange3343

Ad

Answer this question