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

My shop GUI won't work?

Asked by
Vid_eo 126
9 years ago

I'm making a shooter, and I'm making a shop. The problem is, whenever I click on the shop item I'm trying to get, I don't get anything. Here's the script for the button:

repeat wait()
    Player = game.Players.LocalPlayer
Button = script.Parent
Item = game.ReplicatedStorage:FindFIrstChild("GravityCoil")
Cost = 50
Money = Player.leaderstats.Money    
until

Button.MouseButton1Down:connect(function(purchase)
    if Money.Value > (Cost - 1) then
        Money.Value = Money.Value - Cost 
        local a = Item:Clone()
        a.Parent = Player.Backpack
        local b = Item:Clone()
        b.Parent = Player.StarterGear
    end
end)

This is the script for the leaderboard I was using (I gave myself 50 money)

game.Players.PlayerAdded:connect(function(p)
    local stats = Instance.new("IntValue", p)
    stats.Name = ("leaderstats")

    local money = Instance.new("IntValue", stats)
    money.Name = "Money"
    money.Value = 50
end)

Thanks in advance!

1 answer

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
9 years ago

The problem is that you're trying to look for FindFIrstChild, which will give an error. Remember lua is case sensitive! By fixing that small spelling error, the script should work right for you.

Item = game.ReplicatedStorage:FindFirstChild("GravityCoil")
0
Yep. thx Vid_eo 126 — 9y
0
Thumbs up and accept the answer if this helped! Relatch 550 — 9y
0
I accepted :c Right after I typed the question I looked back into the script and found my error :P. Thanks for answering tho :) Vid_eo 126 — 9y
Ad

Answer this question