So I've been scripting and I'm making a Roblox Ninja Warrior, I'm using the velocity cause it's a good friend of mine and I want to make it turn to 0 when a humanoid touches a part.
Script:
function OnTouched(hit) script.Parent.Parent.Thingy.Velocity.X=0 end script.Parent.Touched:connect(OnTouched)
I've been doing Vector3 (Error told me) but it still didn't work so I did this. Still doesn't work! Roblox shows me this when I touch the part:
X cannot be assigned to
Idk wth I gotta do. Anyone tell me what to do and/or fix my script?
You can not write to one property of a Vector value (the same goes for UDim2s, and it's a pain tbh). You have to create a new one entirely.
Example with your code:
function OnTouched(hit) local currentVelocity = script.Parent.Parent.Thingy.Velocity local newVelocity = Vector3.new(0,currentVelocity.Y,currentVelocity.Z) script.Parent.Parent.Thingy.Velocity = newVelocity end script.Parent.Touched:Connect(OnTouched)