when i wrote this line of code which make sure player owns a gamepass to make the button visible in the output it says "attempt to index nil with 'Visible'" please help

local mps = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
if mps:UserOwnsGamePassAsync(player.UserId, 18392789) then
	script.Parent.Visible = true
end
script.Parent.MouseButton1Click:Connect(function()
	player.Character.Humanoid.WalkSpeed = 16
	script.Parent.Visible = false
	script.Parent.Parent.Off.Visible = true
end)

line 4 btw

8 comments

0

At least try to interpret your error message, yes? You attempted to index (set something's property) with Visible, but, that "something" was missing.

0

Usually that happens a lot with localscripts, so I recommend using :WaitForChild()

0

wait a second how can a script.parent be missing

0

still doesnt work

0

im just confused how can a script.parent be missing

0

is script.Parent the button? or something else

0

In this case, you might want to show the explorer

0

script.parent is the button