Using click detector to change vector 3 value not working?

vector3


I want to have the velocity changed when the click detector is clicked. Doesnt change the values so it doesn’t work. I would also like it to change back to zero after a certain time - thanks

You need to call the function in the script.

How would you do that? New to lua my bad

local function onClicked()

script.Parent.Parent.Motor.LinearVelocity.VectorVelocity = Vector3.new(0,0,10)

wait(10)

script.Parent.Parent.Motor.LinearVelocity.VectorVelocity = Vector3.new(0,0,0)

end

Well, to call the function with the MouseClick event you need to do something similar to this:
script.Parent.ClickDetector.MouseClick:Connect(onClicked)

That’s going to be waiting for the next line to be executed, doesn’t relate to your problem at all.

that was just so it stops automatically, but i tried the click function you provided with no luck… Function onClicked() usually works for me

Did you put the code outside of the function though??

i put the code in the parenthesis

Oh my god- why do you need to put the code in parentheses though? Remove those, please.

like i said man im new to this, thought this was something simple but guess i was wrong lol

try

local function onClicked()
script.Parent.Parent.Motor.LinearVelocity.VectorVelocity = Vector3.new(0,0,10000)
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)

wow im stupid i can’t believe i forgot that thank you

everyone does mistakes, also no problem

1 Like