Just a couple notes, your code isn't indented. It took me a while to learn proper formatting for my code but it's extremely important for readability. Basically, any time you're doing anything inside of something else, for example, if statements, you want to indent all the lines in the function, if statement, whatever it is by 4 spaces, you can press tab to do this, and shift plus tab will indent it back 4 spaces
Without formatting
local function()
return 0
end
With formatting
local function()
return 0
end
It just makes it much easier to work on your code.
Another thing, don't use names like "a" or "b". Use descriptive names, it makes your code much easier to maintain, think about it, if you're working on something for weeks, if you make a function called "a" and you come back to work on it a week later because of a bug, you might've forgotten what that function does, whereas with a descriptive name it wouldn't matter if you forgot. I will note however for prototyping and just testing random stuff it's fine to name your variables and functions stuff like that, because you're not gonna be trying to maintain it.
Now for the problems in the code itself.
- Change this line
part.Touched:connect(move())
To this
part.Touched:Connect(move())
Notice how I capitalized the C in "Connect". Almost all functions are named in pascal case (First letter of each word is uppercase)
I don't see anything else wrong in your code. If my changes didn't work, try printing out the part name, are you sure it's the part you want? Or, if it is the part you want, try to start simple, try just moving the part at the start of the game, don't just do a small movement, do a very noticeable one, after that, try adjusting the movement to get it how you like it, after that, try just detecting if the part was touched, after that, try linking up touching the part to the moving action.
1 comment
maybe remove the brackets in line 12 next to move