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

This script for a Shop GUI works in Studio, but not in game??

Asked by
Vid_eo 126
9 years ago

Today I made a Shop GUI. It opens in studio, but in game it doesn't open no matter how many times I click. Any help? (I used a LocalScript fyi)

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)
0
What doesn't it do? Relatch 550 — 9y
0
The shop doesn't open when I click on the shop button. Vid_eo 126 — 9y

1 answer

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

I believe your problem is that you're not letting everything load in quick enough for it to work properly in the script.

Try this:

repeat wait()
    Player = game.Players.LocalPlayer
    Button = script.Parent
    Item = game.ReplicatedStorage:WaitForChild("GravityCoil") --Method of waiting for it to load in
    Cost = 50
    repeat wait() until Player.leaderstats --Different method of waiting for them to load in
    repeat wait() until Player.leaderstats.Money
    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)

Anyways, I believe the script should work now if everything else is correct the way it is.


Hope this helped, and if you have any further problems/questions, please leave a comment below :P

-Dyler3

0
He used this video to help him i'm pretty positive; https://www.youtube.com/watch?v=Hcve7MHeGLc. So, it should work if he copied the script there. Relatch 550 — 9y
0
Still isnt working, idk why Vid_eo 126 — 9y
0
I did, it works in studio, but not in a server Vid_eo 126 — 9y
0
Well if this is the case, it should actually work perfectly fine. Adding in this wouldn't hurt however. Just make sure that all of the names and everything are correct, and that everything is where it's supposed to be. dyler3 1510 — 9y
View all comments (4 more)
0
Wanna see the place I'm talking about? :3 Vid_eo 126 — 9y
0
Sure dyler3 1510 — 9y
0
ty dyler!! Vid_eo 126 — 9y
0
No prob :P dyler3 1510 — 9y
Ad

Answer this question