Well there is an error on this script and it says: CoinGui is not a valid member of PlayerGui. Well it is a valid member because I saw it in my player gui while testing. It makes no sense. Here is the script that is causing the problem.
local coins = script.Parent.Parent.CoinGui.Coins for i, v in pairs(script.Parent.Frame:GetChildren()) do if v:IsA("TextButton" or "ImageButton") then v.MouseButton1Click:connect(function(player) if v.Name == "GrapplingHook" then if coins.Value > 349 then coins.Value = coins.Value - 350 game.Lighting.GrapplingGun.Parent = player end end end) end end
How is this wrong? Or is Studio just glitching?
Some items don't load instantly so you need to use WaitForChild to wait until they're available for use.
local coingui = script.Parent.Parent:WaitForChild("CoinGui") local coins = coingui:WaitForChild("Coins") for i, v in pairs(script.Parent.Frame:GetChildren()) do if v:IsA("TextButton" or "ImageButton") then v.MouseButton1Click:connect(function(player) if v.Name == "GrapplingHook" then if coins.Value > 349 then coins.Value = coins.Value - 350 game.Lighting.GrapplingGun.Parent = player end end end) end end