The error occurred in this script;
1 | while true do |
2 | if script.Parent.Parent.Parent.Parent.Speed.Start.Value = = true then |
3 | script.Parent.velocity.X = script.Parent.Parent.Parent.Parent.Speed.Speed.Value |
4 | else |
5 | script.Parent.velocity.X = 0 |
6 | end |
7 | wait() |
8 | end |
the second to last Speed in
script.Parent.velocity.X = script.Parent.Parent.Parent.Parent.Speed.Speed.Value
is the Intvalue, and the one before that is a model called Speed.
Also, Start is a BoolValue in the model Speed.
But why doesn't this work?
Your problem is that you're trying to individually manipulate the X axis
- You can't do this. The Individual X, Y, and Z axis scales are read-only. Meaning that you can only take information from them, not assign information to them.
So to fix, you need to assign the velocity property with a Vector3 on all axises at the same time.
Also, I suggest you use the Changed event to set the property, rather than a while
loop, it's much more efficient.
1 | local val = script.Parent.Parent.Parent.Parent.Speed |
2 |
3 | val.Speed.Changed:connect( function (change) |
4 | if val.Start.Value = = true then |
5 | script.Parent.velocity = Vector 3. new(change, 0 , 0 ) |
6 | end |
7 | end ) |
You can't directly set those values. You have to set the full thing for example you can't do:
1 | part.Position.X = 6 |
you would have to do
1 | part.Position = Vector 3. new( 6 , part.Position.Y, part.Position.Z) |
I'm not sure exactly why this is but I believe has to do with them being read only or something similar.
I hope you can apply this to your code. If you need help doing so, ask.