Where do I start with this workout type of script?

Hey Developers!

So, I’m making a Training Campus, for a Police Training Campus.

I have this thing I have in my mind how I want it to plan out but I have no CLUE on where to start.

So, I’m trying to make like a workout system, with push-ups and jumping jacks. And to make it more “competition” in order to complete 1 jumping jack or push-up, you have to put a puzzle together such as to different keybinds.

Summarize: Like the tool will pop up a TextLabel with a Random Combination on which two keybinds you would click. Such as If You click like K + V you do the animation. (jumping jack when you have the jumping jack tool equipped.)

So, I have a tool, with no handle. (Because I don’t want the hand out while your doing an animation.)

What I’ve already tried; I decided to search it up on youtube, but no results except Firestone’s Training System. Which was just a showcase of course.

So, Where exactly will I start?

So far I have: A Tool, With no handle. And an empty script waiting for some typing.

Thanks for reading, if you still don’t understand what I mean, please let me know.

If I understand correctly, you want a tool to listen for certain inputs. It’s simpler code-wise if you don’t need K & V to be pressed simultaneously, however it shouldn’t be too hard.

To get a rough structure started I’d start by writing function names, such as the following:

-- Tool code
local currentTask = {} -- Set this to letters needed to be press
-- Ex: {'K', 'V'}

function updateUI()
    -- Update text on your textlabel (or whatever you choose)
end

function generateTask()
    -- Generates a combination of letters, currentTask will be set to this
    updateUI() -- Make UI display new task
end

function taskCompleted()
    -- Whatever you want to happen
    -- You will need to fire a remoteEvent if you want the server
        -- to know of this.
    currentTask = generateTask() -- Create a new task
end

-- Pseudo code for UserInputService:
function keyPressed(key)
    -- Is key in currentTask? remove it. (Simple non-simultaneous solution)
    -- If you want simultaneous, check if key.isDown() (or similar) for
        -- the combination
    if currentTask == {} then
        taskCompleted()
    end
end

tool.Equipped:Connect(function()
    currentTask = generateTask()
end)

To listen for inputs, I’d recommend reading UserInputService (roblox.com).

I hope this is enough for you to get started. If you have any further questions feel free to reply.
Note: You might need to de-activate “requiresHandle” on the tool.

But does this trigger a certain animation?

It can, all depends on the code you put in the respective things. I am not very experienced with Animations.

My guess is that you need the animation to be played from the Server, so everyone can see it.

As I mentioned you need to fire a RemoteEvent. The code responding to the fired Remote can then play the animation of your choosing.

Keep in mind though, I don’t know how animations work. However, when you figure that how they work, it should just be a matter of writing that code on the server.

-- Server code
function workoutCompleted(plr)
    -- Decide which workout was completed. Look at their position OR
        -- take ``workout`` as an input and trust the user. Your choice.
    -- Use name of completed workout to find correct animation
    -- Play said animation on plr.Character
end

<your RemoteEvent>.OnServerEvent:Connect(workoutCompleted)

edit: Added “-- Server code”

Alright, thanks. I’ll try to figure the rest out,

Best of luck! Don’t forget to mark this as solved once you are done.

It worked sort of, I’ll play around with it until I solve my issue. Thanks!

1 Like