I have been trying to make an inventory gui script that when you touch a brick named TouchPart it gives you 30 Wood and you can craft a axe by pressing a gui button for 30 wood but for some reason its not working anyone got any ideas on my its not working?
local GUI = script.Parent
local inv = script.Parent.Inventory
local invParts = inv:GetChildren()
local buyFrame = GUI.BuyFrame
local craftAxe = GUI.CraftAxe
local plr = game.Players.LocalPlayer
local touching = false
local inGUI = false
workspace.TouchPart.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
for i, v in pairs(invParts) do
wait(0.5)
if v.SlotValue.Value == "" then
v.SlotValue.Value = "Wood"
v.Ammt.Value = 30
v.SlotLabel.Text = v.Ammt.Value
v.SlotImage.Image = "http://www.roblox.com/asset/?id=539465370"
break
elseif v.SlotValue.Value == "Wood" then
v.Ammt.Value = v.Ammt.Value - 30
v.SlotLabel.Text = v.Ammt.Value
break
end
end
end
end
end)
craftAxe.MouseButton1Click:connect(function()
for i, v in pairs (invParts)do
wait (0.5)
if v.SlotValue.Value == "Wood" then
if v.Ammt.Value >= 30 then
v.Ammt.Value = v.Ammt.Value - 30
v.SlotLabel.Text = v.Ammt.Value
for i, v in pairs(invParts)do
wait(0.5)
if v.SlotValue.Value == "" then
Print("A")
v.SlotValue.Value = "WoodAxe"
v.Ammt.Value = 1
v.SlotLabel.Text = v.Ammt.Value
v.SlotImage.Image = "http://www.roblox.com/asset/?id=540955027"
break
end
end
end
end
end
end
end)

1 comment
try writing this: if v.Name == "SlotValue" then and then on a different line write: if v.Name == "Ammt" then