#Click detector issue

1 messages · Page 1 of 1 (latest)

vapid nebula
#

Hello I would like that once I click a part
He got an attachment, so I created a click detector then out a script but the script doesn't seem to work. Can someone explain to me why?

stiff siren
vapid nebula
stiff siren
#

cause in your script you are trying to reference the part directly as its parent, which is giving you the wrong object

worldly eagleBOT
#

studio** You are now Level 9! **studio

vapid nebula
#

It

#

And the results

#

Didn't change

#

No attachment was created

stiff siren
#

Now instead of script.Parent.MouseClick you need to get the .MouseClick of the click detector

#

.MouseClick is an event that comes from the click detector object

#

Im actually suprised it doesnt give an error ngl

vapid nebula
#

Mmh ok

#

Let me try

vapid nebula
stiff siren
vapid nebula
#

Still same Result, I must have done something wrong again

stiff siren
#

Its definitely giving an error

#

in your script, attachment needs to be capitalized in Instance.new()

#

if it isnt then an error will pop up

#

where is the script located in the explorer?

#

and is there potentially a different script that is disabling this one?

vapid nebula
#

No error

#

Appear

vapid nebula
stiff siren
#

All the way up, workspace, server storage, places like that

worldly eagleBOT
#

studio** You are now Level 14! **studio

stiff siren
#

If the script is under server storage it wont run for example

#

Also you can check if its running by adding a print statement to the start of the script

vapid nebula
stiff siren
#

hmm

#

Put a print statement inside of the click function, to see if it is properly reading the input

vapid nebula
#

Once I clicked

#

The one I asked to be printed

#

Wasn't

#

Printed

stiff siren
#

show script, something is wrong with the event then

#

to where the lines of code creating the attachment isnt running

vapid nebula
stiff siren
#
ClickDetector.MouseClick:Connect(function(click)

end)

You already have reference to the click detector, so there is no reason to not just use the variable you made, also you removed the mouse click event

#

which is why it isnt working

#

change it to what I have above

vapid nebula
limpid sand
#

why are you using FindFirstChild?

#

its not necessary here

stiff siren
vapid nebula
stiff siren
#

you can get the click detector without it

limpid sand
#

findfirstchild is useless if you're not checking if the instance is nil, it just gives you a more confusing error (attempt to index nil with ___ instead of ___ is not a valid member of ___)

vapid nebula
limpid sand
vapid nebula
stiff siren
#

should have been more specific when I said get rid of find first child ig

local part = script.Parent
local ClickDetector = part.ClickDetector
ClickDetector.MouseClick:Connect(function(click)
  -- code to make attachement
end)
#

Do this ^

#

You went back to trying to get .MouseClick from the part (script.Parent), which doesnt exist

#

So you needed to keep the click detector variable

vapid nebula
#

Once again nothing is printed

stiff siren
vapid nebula
stiff siren
#

oof

vapid nebula
thin coral
#

explorer aswell

stiff siren
#

ClickDetector.MouseClick
not
script.Parent.MouseClick

vapid nebula
#

oops

#

sorry

stiff siren
#

remember the parent is the part, and we need the .MouseClick event from the click detector

oak pivot
stiff siren
oak pivot
#

OH

#

Attachment

stiff siren
#

we are fixing a problem where the function isnt running

oak pivot
#

not attachment

stiff siren
#

i mentioned it earlier

oak pivot
#

oh ok

thin coral
oak pivot
#

its a turtle :sobb:

thin coral
#

its a cucumber

stiff siren
#

🐢

thin coral
stiff siren
vapid nebula
#

Sorry but no

thin coral
#

ima crashout if you not send a pic of your script AND explorer

stiff siren
#

is there still no print or is there an error

stiff siren
vapid nebula
stiff siren
#

ok nvm we need new code

oak pivot
#

put the print before the attachment code see if it prints

#

oh

#

with instance.new

#

set the parent last

vapid nebula
thin coral
stiff siren
#

im gonna crash out, send code

thin coral
#

JUST SCREENSHOT UR WHOLE SCREEN PLZ

vapid nebula
thin coral
#

BRO

#

IM

#

CRASHING

#

OUT

vapid nebula
#

OOOOOh NO

thin coral
#

THAT GOTTA BE RAGEBAIT

vapid nebula
#

SORRY

oak pivot
#

bro parent needs to be set last and attachment needs a capital A

#

local part = script.Parent
local ClickDetector = part.ClickDetector
ClickDetector.MouseClick:Connect(function(click)
local attch = Instance.new("Attachment")
attch.Name = "NodeAttachment"
attch.Position = Vector3.new(0,1,0)
attch.Parent = part
end)

#

THIS WORKS

stiff siren
#

the parent doesnt have to be set last, the changes to the other properties will still apply

oak pivot
thin coral
#

the cucumber can only think about the attachment

stiff siren
#

weird

oak pivot
#

but anyways this works

#

i testedin studio

stiff siren
# vapid nebula

did you change the name of the click detector or smth, why is it referenced differently here

thin coral
#

bro the unskilled one doesnt even know himself

vapid nebula
#

fulll screen

thin coral
#

like he cant even screenshot his whole screen

#

OMG

oak pivot
#

this is ragebait

vapid nebula
#

I swear

#

I'm not

thin coral
#

WHY IS IT CLICKDETECTORCLICK

#

BRO

oak pivot
#

PART.CLICKDETECTOR NOT PART.CLICKDETECTORCLICK

vapid nebula
#

Ok ok

thin coral
#

WHERE IS YOUR CONSOLE BRO

#

WHY IS IT WHITEMODE

#

I HAVE SO MANY QUESTIONS

oak pivot
#

if he did he could see clickdetectorclick is not a valid member of blah blah blaj

stiff siren
vapid nebula
thin coral
#

how is he level 5

#

and doesnt have the console open

oak pivot
#

zyos do u know how to do the '''lua thing

stiff siren
#

does it work?

oak pivot
thin coral
vapid nebula
oak pivot
#

it does ur lying

stiff siren
oak pivot
#

local part = script.Parent
local ClickDetector = part.ClickDetector
ClickDetector.MouseClick:Connect(function(click)
local attch = Instance.new("Attachment")
attch.Name = "NodeAttachment"
attch.Position = Vector3.new(0,1,0)
attch.Parent = part
end)

#

copy and paste this

#

and it will work

oak pivot
#

i have it in studio and it works

vapid nebula
#

YES YESSSSS

#

IT WORKED

#

LETS GOOOOOOOOOO

#

YOUPIE

thin coral
#

ur so dumb respectfully

#

gj

vapid nebula
#

I just

#

Started today

thin coral
#

slow

vapid nebula
#

Not tutorial

thin coral
#

alr

vapid nebula
#

No anything

#

I tried to do something complex

#

For my friend

thin coral
#

dont do that

stiff siren
#

its ok to use a tutorial

thin coral
#

yo cucumber

#

@oak pivot

vapid nebula
#

Thanks you guys

thin coral
vapid nebula
#

For helping in my future project to be a great scripter one day