I am trying to make a shop gui and one of the items is Grappling Hook. I have this script there are no errors but yet when I test it in studio it does not give me the grappling hook. I do have enough coins too when I test it. Here is the script.
local coins = script.Parent.Coins for i, v in pairs(script.Parent.Frame:GetChildren()) do -- i got this idea from berezaa and yes it does work if v:IsA("TextButton" or "ImageButton") then v.MouseButton1Click:connect(function() if v.Name == "GrapplingHook" then -- these are the parts I'm concerned about if coins.Value > 349 then coins.Value = coins.Value - 350 local clone = game.Lighting.GrapplingGun:Clone() clone.Parent = game.Players.LocalPlayer.Backpack end end end) end end
I believe your problem is on the 4th line. Computers do exactly what you tell them, but sometimes can't understand some things that make sense to you and others as it.
In your example, you're trying to make the code continue if v is a TextButton or an ImageButton. The way you're writing it, the computer will not understand it and will only take the TextButton into account and will ignore the or bit altogether. The way you should write it is like this:
if v:IsA("TextButton") or v:IsA("ImageButton") then