I’ve seen many RO-Soccer league developers start out with a generic MPS Open sourced pitch with no idea how to modify their tools, and I’ll admit, I was like that half a year ago when I only just started properly coding.
With no resources available at the time, I really struggled but soon enough I got how they work.
I’m writing this to help other beginners modify their own tools.
This script was taken by my rewrite of TPS 12 tools, (Dribble + LMB) originally made by @TAYFUN7.
Here we’re just setting up the variables. They’re essential to any script in tools.
local Mech = require(script.Parent.Parent:WaitForChild("Mechanics")) -- Controls debounces
local EditWelds = require(script.Parent.Parent:WaitForChild("EditWelds")) -- Controls editing the limbs
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse() -- Defines the player and the mouse
local character = Player.Character -- Defines the character
if not character or not character.Parent then
character = Player.CharacterAdded:wait() -- Defines the new character if the player resets
end
Enabled = false -- The variable for if the tool is enabled
Kicked = false -- The variable to see if the 'react' can be registered
This part ensures that the tool is equipped so that the stuff that happens only happens when it’s equipped;
script.Parent.Equipped:Connect(function()
Enabled = true -- If the tool is enabled.
end)
script.Parent.Unequipped:Connect(function()
Enabled = false -- If the tool isn't enabled anymore.
end)
This part checks if the tool is eligible to be used;
Mouse.Button1Down:Connect(function() -- Once the left mouse button has been clicked
if Enabled == false then return end -- If the tool isn't enabled then dont go any further into the script
if Mech.CheckDebounce() then return end -- If the cooldown for any other tools (or this tool) has been activated then dont go any further into the script
Now this bit does all the things that the tool has to do if everything is fine;
local LH = character.Torso["Left Hip"] -- Joint for the Left Leg
local RH = character.Torso["Right Hip"] -- Joint for the Right Leg
LH.MaxVelocity = "0.2" -- How fast the joint is supposed to move in a frame
RH.MaxVelocity = "0.2" -- How fast the joint is supposed to move in a frame
EditWelds.EditWeld("Right Leg", CFrame.new(0.5,-1.8,-0.5) * CFrame.fromEulerAnglesXYZ(math.pi/8,0,0)) -- Editing the right leg's weld position (you don't have to worry about editing this because its all basically the same anyways)
character.Humanoid.WalkSpeed = 22 -- Making the player walk faster
Mech.SetDebounce(true) -- Setting the cooldown so no other tools can work during this
Kicked = true -- Setting the react to be eligible to be done
This part is what happens after everything is done.
wait(0.7) -- Waits 0.7 seconds before proceeding
EditWelds.ResetWelds() -- Resets the player welds so the leg goes back to it's original position
Kicked = false -- Setting the react to be ineligible
wait(0.1) -- Wait 0.1 seconds
Mech.SetDebounce(false) -- Sets the cooldown to not be true so all the tools can work again
Now the very last bit handles the react so the ball can actually move when you touch it while doing this;
character["Right Leg"].Touched:Connect(function(hit) -- If the Player's Right Leg has been touched then
if Kicked == false then return end -- If the react is ineligible then don't continue any further into the script
if hit.Parent.Name ~= "TŞ Balls" then return end -- If the ball's parent's name is NOT 'TŞ Balls' then don't go any further into the script.
game:GetService("ReplicatedStorage"):FindFirstChild("TŞEvents"):FireServer("Network Ownership", hit) -- Sets the ball's network ownership to the player to stop the ball from lagging when it's just rolling
Kicked = false -- Setting the react to be ineligible so you dont double touch the ball
local F = Instance.new("BodyVelocity") -- Creates a Force
F.Parent = hit -- Makes the force act on the ball
F.Name = script.Name -- Make the force's name the script's name
F.velocity = character["Right Leg"].CFrame.lookVector * 30 -- The force is where the Right Leg is looking (so if your right leg was looking towards the goal then the ball would go to the goal) and its given a certain value to go against (the higher the number, the faster the ball would go)
F.maxForce = Vector3.new(4e+006,1e+003,4e+006) -- The maximum force it's allowed to give the ball
game.Debris:AddItem(F,0.3) -- This destroys the Force within 0.3 seconds without stopping the code so it doesn't keep the ball moving
end)
And it’s the end! Thanks for reading for this long! This is my first tutorial so please give me feedback on how I can improve.
Link for the game I used for this tutorial;
https://www.roblox.com/games/8655909068/TPS-12-Practice-Arena-Remade