local name = script.Parent.Parent.ItemName local resources = script.Parent.Parent.Resources if script.Parent.MouseButton1Down then function bow() if name.Text == "Bow" then print("Bow Given") elseif name.Text == "Select a Item" then print("Not Enough Materials") end end bow() end
This is my script, I'm just testing out a crafting GUI and when I test the game it immedietaly prints Not Enough Materials and when I click the 'Craft' button (which should run the script again) nothing new prints, even though it should since the name.text is Bow.
Any Help is appreciated.
For first, you created a function in "MouseButton1Down", for this you need to use local function
, and your click is incorrect
and use MouseButton1Click. you can see more here: MouseButton1Click - Wiki page
For use functions and click you need to use this:
function print_text(text) print(text) end script.Parent.MouseButton1Click:Connect(function() print_text("Hello") end)
Here is your fixed script:
local name = script.Parent.Parent.ItemName local resources = script.Parent.Parent.Resources function bow() if name.Text == "Bow" then print("Bow Given") elseif name.Text == "Select a Item" then print("Not Enough Materials") end end script.Parent.MouseButton1Click:Connect(function() bow() end)
Hope it helped :D
Errors? tell-me on comments.