How would I make a Payload Script? (like in TF2)

Hello Dev Forum, I need a little help.

I’m working on a TF2 inspired Roblox game and I’m currently trying to make a Payload gamemode for it. The issue is I have no idea where to start with this one.

Pretty much I’m trying to make a script that moves a model to certain parts in a sequence, once the model reaches one part it starts to move to another one. And I also want to make it so the cart only moves if a player is standing near it. (& who is on a specific team preferably)

– ive also still gotta make a script where if the cart moves over a specific pad the game will have more time added to it, but this isn’t my main priority right now. –

I don’t know exactly how I’d achieve this, I haven’t seen a lot of posts going into depth on how to keep a model at its last position when you step away from it, which is sort of preventing me from writing any code of my own. (And I don’t know if I should use tweens or gradually moving the models cframe.)

I’m not looking for a full script to immediately slam into my game, I really just need some examples I can branch off of.

Any help would be really appreciated, Thanks!

3 Likes

Well it really depends on how you are moving the model. Ultimately you need to check every player to see if they are in range and stop the model if not or start/continue if they are.

The simplest form of implementation is like

while true do
    if IsAnyPlayerInRange() then
        movePart1Step()
    end
end

Other things like using tween service could technically work, but you need to have it start and stop based on a query loop that always runs. So when the loop sees nobody it calls stop and when it sees someone it calls start.

1 Like

Ooh Alright, how would the function for moving the part look? (preferably not for tweening, forgot to clarify)

Why would you not want to use tweens? Feels like the simplest and most beneficial means to doing this.

2 Likes

you could have an invisible track and just push the cart along with a BodyMover

I expected that tweens would be a little difficult for me to code, If you can give an example of how that would work I’d greatly appreciate it.

I actually found a good way to do this with tweens using a Touched function. I thought that tweens are very complicated but it turns out they’re quite simple! I think i’m good to make the rest of this code myself, thanks for the help y’all.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.