Hopefully i get this right this time :'), so i had a look and all the post that a similar to mine have been removed for duplication or arent on here anymore and nothing helps on Wikipedia.
((Buying Script for my Sword Shop Gui )))) (i use gold , dont know if it matters)
This is my explanation. I have spent a ridiculous amount of time trying to fix this shop up and i could really use some help as it would help me progress in my game, I've tried scripting it in so many ways i tried using other peoples scripts. It is set up to a text button and when you click on it, it opens up the shop but when you purchase one of the items it takes the gold needed but the item doesn't go into my inventory.
I got a ranged shop, staff shop, spell shop,sword shop, armor shop and its all connected as you can see from the script bellow but yet after checking over it a billion times going through all the scripts i cant seem to find a single error so i need help from experienced scripters in helping me to find the solution for my new rpg roblox game that i'm making . since everything is connected once i work out how to get my sword shop to work everything else will work. is been a major setback on the game hopefully this is enough information i will be gladly to give you my output or anything else you need, just need some help..
{{{{{ Buying Script }}}}}
local items = script.Parent.Frame:GetChildren()
for i = 1, #items do
function buy()
Cash = script.Parent.Parent.Parent.Parent.leaderstats:FindFirstChild(items[i].Currency.Value)
h = Instance.new("Hint")
h.Parent = script.Parent.Parent.Parent
if Cash.Value >= items[i].Cost.Value then
Cash.Value = Cash.Value - items[i].Cost.Value
toolca =
Game.ReplicatedStorage:FindFirstChild(script.Parent.Folder.Value):FindFirstChild(items[i
.ItemName.Value):Clone()
toolcb =
Game.ReplicatedStorage:FindFirstChild(script.Parent.Folder.Value):FindFirstChild(items[i].
ItemName.Value):Clone()
toolca.Parent = script.Parent.Parent.Parent.Parent.Backpack
toolcb.Parent = script.Parent.Parent.Parent.Parent.StarterGear
print("Successfully bought!")
h.Text = "You have bought " ..items[i].ItemName.Value.. "!"
else print("Insufficient money!")
h.Text = "You don't have enough " ..items[i].Currency.Value.. "!"
end
Game:GetService("Debris"):AddItem(h, 2)
end
items[i].BuyButton.MouseButton1Click:connect(buy)
end
i'm just providing the text button script just encase dont know if you'll need it.
{{{{{ TEXT BUTTON SCRIPT }}}}}
button = script.Parent
function onTouch(part)
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local player = Game.Players:GetPlayerFromCharacter(part.Parent)
if player ~= nil then
local GUI =
Game.ReplicatedStorage:FindFirstChild(script.Parent.ShopGUI.Value)
local AlreadyHaveGUI =
player.PlayerGui:FindFirstChild(script.Parent.ShopGUI.Value)
if AlreadyHaveGUI == nil then
GUI:Clone().Parent = player.PlayerGui
else print("Already have GUI!")
end
end
else print("Humanoid not found!")
end
end
button.Touched:connect(onTouch)
OUTPUT!
21:12:51.101 - Plugin_142315402.Close.Shop:1: attempt to index field 'Parent' (a nil value)
02
21:12:51.102 - Script 'Plugin_142315402.Close.Shop', Line 1
03
21:12:51.103 - Plugin_142315402.Open.Shop:1: attempt to index field 'Parent' (a nil value)
04
21:12:51.104 - Script 'Plugin_142315402.Open.Shop', Line 1
05
21:12:51.105 - ItemName is not a valid member of TextButton
06
21:12:51.106 - Script 'Plugin_142315402.Shop Gui.Main.Close.Shop', Line 2
07
21:12:51.107 - ItemName is not a valid member of TextButton
08
21:12:51.107 - Script 'Plugin_142315402.Shop Gui.Main.Open.Shop', Line 2
09
21:12:51.110 - Plugin_142315402.Main.4.Shop:1: attempt to index field 'Parent' (a nil value)
10
21:12:51.110 - Script 'Plugin_142315402.Main.4.Shop', Line 1
11
21:12:51.111 - Plugin_142315402.Main.3.Shop:1: attempt to index field 'Parent' (a nil value)
12
21:12:51.112 - Script 'Plugin_142315402.Main.3.Shop', Line 1
13
21:12:51.113 - Plugin_142315402.Main.1.Shop:1: attempt to index field 'Parent' (a nil value)
14
21:12:51.114 - Script 'Plugin_142315402.Main.1.Shop', Line 1
15
21:12:51.115 - Plugin_142315402.Main.Close.Shop:1: attempt to index field 'Parent' (a nil value)
16
21:12:51.116 - Script 'Plugin_142315402.Main.Close.Shop', Line 1
17
21:12:51.117 - Plugin_142315402.Main.Open.Shop:1: attempt to index field 'Parent' (a nil value)
18
21:12:51.118 - Script 'Plugin_142315402.Main.Open.Shop', Line 1
19
21:12:51.119 - Plugin_142315402.Main.5.Shop:1: attempt to index field 'Parent' (a nil value)
20
21:12:51.120 - Script 'Plugin_142315402.Main.5.Shop', Line 1
21
21:12:51.120 - Plugin_142315402.Main.6.Shop:1: attempt to index field 'Parent' (a nil value)
22
21:12:51.121 - Script 'Plugin_142315402.Main.6.Shop', Line 1
23
21:12:51.122 - Plugin_142315402.Main.7.Shop:1: attempt to index field 'Parent' (a nil value)
24
21:12:51.123 - Script 'Plugin_142315402.Main.7.Shop', Line 1
25
21:12:51.124 - Plugin_142315402.Main.2.Shop:1: attempt to index field 'Parent' (a nil value)
26
21:12:51.125 - Script 'Plugin_142315402.Main.2.Shop', Line 1
27
21:12:51.158 - pickitems is not a valid member of ScreenGui
28
21:12:51.159 - Script 'Plugin_291328554.KinqStudioPlugin', Line 59
29
21:12:51.161 - nameofdagui is not a valid member of Workspace
30
21:12:51.162 - Script 'Plugin_291328554.KinqStudioPlugin.KinqStudioPluginShop.Script', Line 1
31
21:12:57.059 - Script 'Plugin_291328554.KinqStudioPlugin.KinqStudioPluginShop.Inventory.gui3d.LocalScript', Line 4
32
21:12:57.060 - Stack End
33
21:12:57.061 - Part is not a valid member of Lighting
34
21:12:57.062 - Script 'Plugin_291328554.KinqStudioPlugin.KinqStudioPluginShop.Shop.gui3d.LocalScript', Line 4
35
21:13:42.004 - Players.Player.PlayerGui.WeaponShopGUI.TextLabel.BuyScript:10: attempt to index a nil value
36
21:13:42.005 - Stack Begin
37
21:13:42.006 - Script 'Players.Player.PlayerGui.WeaponShopGUI.TextLabel.BuyScript', Line 10
38
21:13:42.006 - Stack End
39
21:13:44.352 - Players.Player.PlayerGui.WeaponShopGUI.TextLabel.BuyScript:10: attempt to index a nil value
40
21:13:44.353 - Stack Begin
41
21:13:44.353 - Script 'Players.Player.PlayerGui.WeaponShopGUI.TextLabel.BuyScript', Line 10
42
21:13:44.354 - Stack End

2 comments
Show us the output. There's gonna be some mistake with the objects.
OUTPUT is above is someone could try to help me out that would be amazing