Attempt to index nil with 'MouseButton1Click'

I do not know what is going wrong here can someone please help explain it?

script.Parent.MouseButton1Click:Connect(function()
	for i,v in pairs(game.Players:GetDescendants()) do
		if v:IsA("Player") then
			local highlightnew = game.ReplicatedStorage.Highlight:Clone()
			highlightnew.Parent = v.Character
		end
	end
	task.wait(3)
	for i,v in pairs(game.Players:GetDescendants()) do
		if v:IsA("Player") then
			v.Character.Highlight:Destroy()
		end
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Ok when making posts here I must ask you to include more info.
Such as:

  • Script Type
  • Script Parent
  • Relevant errors (You put it in the title so we good with this one)
  • Any other useful information

make sure it is a localscript/ a clickable instance

2 Likes

Could you include more info? I’m confused as much as you are

script.Parent is not a clickable instance

Its inside a button so the mousebutton one click is fine

What happens is in another script I clone a gui into another gui and when that happens iot says the message, the funny thing is that this script has nothing to do with it and is not in the same screen gui or being cloned but it has the same script as the item being clone but I do not know why it is being brought up.

Here is the cloning script:

local info = script.Parent.Parent.Parent.Info.Frame

script.Parent.MouseButton1Click:Connect(function()
	info.desc.Text = script.Parent.Desc.Value
	info.name.Text = script.Parent.Name
	info.image.Image = script.Parent.Frame.image.Image
	local newbtn = game.ReplicatedStorage.Abilitesbtn.See:Clone()
	newbtn.Parent = script.Parent.Parent.Parent.Parent.Parent.Ability
	for i,v in pairs(script.Parent.Parent.Parent.Parent.Parent.Ability:GetDescendants()) do
		if v:IsA("ImageButton") then
			v:Destroy()
		end
	end
end)

Nah im stupid I cloned it then deleted it :sweat_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.