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

Gui Weapon Shop fixes? [Still UNANSWERD :( ]

Asked by 9 years ago

I tried making a gui weapon shop but it didn't. can you guys please help me check the script:

player = script.Parent.Parent.Parent.Parent.Parent money = player.leaderstats.KOs price = 3 tool = game.Lighting:findFirstChild("Knife")

function buy() if money.Value >= price then money.Value = money.Value - price local a = tool:clone() a.Parent = player.Backpack end end script.Parent.MouseButton1Down:connect(buy)

i also tried taking free models and editing them, and watching tutorials but they DIDN'T work.....

0
code block please! EzraNehemiah_TF2 3552 — 9y
0
ok now a code block.. gametestworker 0 — 9y
0
Is it in a local script? aquathorn321 858 — 9y
0
no just normal gametestworker 0 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

After reviewing the code, it looks fine. You just needed to put it in a local script.


--Assuming this is a local script inside the button inside the Gui local player = game.Players.LocalPlayer local money = player.leaderstats.KOs local price = 3 local tool = game.Lighting:FindFirstChild("Knife") script.Parent.MouseButton1Down:connect(function() if money.Value >= price then money.Value = money.Value - price local a = tool:Clone() a.Parent = player.Backpack end end)
Ad
Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

Well, since you haven't gotten an answer yet, I'll try to help. There doesn't appear to be anything wrong with your script, however the problem might be with finding the player, or the knife. Make sure that there's a knife in the Lighting before running the script, and make sure that you're leading it to the correct Parent. To test if those work correctly, do this in a separate script, that has the same parent(Make sure your output window is open):

if player = script.Parent.Parent.Parent.Parent.Parent then
    print(player.Name) --If it prints the correct players name, it works fine.
else
    print("Error")
end

To make sure the knife part is correct, do this:

if game.Lighting:findFirstChild("Knife") then
    if game.Lighting:findFirstChild("Knife"):IsA("Tool") then
        print("Knifes fine")
    else
        print("Error")
    end
else
    print("Error")
end

If either of these come up with an error, then look back at where all the objects are placed, and what you're leading your script to find. This is the best I could do with the info we had, so I hope it helped :P . If not, sorry.

Answer this question