How would you plan out scripts

Hello, I am looking for better methods on how you would go on to plan out something and then implement it without getting too confused. Since I have even started scripting 1 year ago I still dont know a good method to do this.

2 Likes

So this would be a very simple example using print(). For example you wanted to set a player’s speed to 20:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character.Humanoid.WalkSpeeed = 20
    end)
end)

Let’s just say you were not sure if the individual lines would run. So you would do something like:

game.Players.PlayerAdded:Connect(function(player)
    print(player.Name)
end)

So the output will be (in my case) “DevOkami”. Now I know that it works, I would do:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        print(character.Parent.Name) --Or anything else that lets you know the character is a character, just play around.
    end)
end)

And finally to check if the WalkSpeed actually changes, we can do:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        print(character.Humanoid.WalkSpeeed)
    end)
end)

And it should be 16. Something like that, just to save you from writing the entire script beforehand. Note that for a relatively simple script like this you should not take so many steps, but if you are having problems drafting out scripts then this would help (in my opinion) haha.

1 Like

I suppose it depends on what you are trying to create.

If you are making a small part of a larger system it is always best to have a whiteboard of some sort that you can reference - have it include things like what you want to achieve, API services that can get you there, and steps you will take to reach the goal. This keeps you focused, on track, and saves you the time of having to check the DevForum/API Reference every few minutes.

If you are making a smaller script, something under 75 lines, I personally find it easier to just sit down and script it line by line without reference rather than developing a plan of any sort. It’s really about preference though, so if it works better for you to draft a plan in the fashion I had presented prior, than by all means.

When I know the script is going to be around 50 lines or less, I just go for it line by line and then run it afterwards, then script analysis and output will make it easy to target any mistakes I made. If I’m writing a much longer script for something that’s somewhat complex, then I still go for it but I use pseudo script wherever my mind’s kinda foggy on what to do. Just remember that the computer is stupid as hell and it’s you have to educate it on every single excruciatingly small step.

In case anyone reading this hasn’t heard of pseudo code, it’s where you write the tiniest step by step instructions that you want the computer to follow, but without syntax, you convert it to syntax afterwards when you’re better versed on what you need from the computer.