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.....
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)
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.