btw I completely separated the code into a server script and a local script, if anybody was curious about the code and wanted to use it for their own games here you go, you’ll need to use Tag Editor though I heavily suggest to just wait for the Studio Tag Editor that Roblox will be adding soon!
and just a heads-up the barrier uses like 2 modules and its kind of long blablabla, just do a barrier yourself with this code if that’s what you want, or just ask me if you really need it.
DO NOT rotate the part at all, put an attachment inside of the jumppad part and put it where you want the player to go, the script will do the rest, however if you know more than me then feel free to edit the script to whatever you need it to do, i made it this way because i work with a friend and i dont want him to have the need to edit the script and rather just simply move the attachment.
ServerScript for the jumpads:
local debugging = false
--//Scripting...
local CollectionService = game:GetService("CollectionService")
--// Locals^
local function onJumpPad(tag, hit)
local debounce = false
if not debounce then
debounce = true
task.spawn(function()
local char = hit.Parent
local HRP = char:FindFirstChild('HumanoidRootPart')
local Att0 = Instance.new('Attachment'):Clone()
local bodyVelocity = Instance.new('BodyVelocity'):Clone()
local cooldown = tag:GetAttribute("Cooldown")
local attDistance = tag:FindFirstChild('attDistance')
Att0.Name = 'linearVelocityAtt0'
Att0.Parent = HRP
bodyVelocity.P = 3000
bodyVelocity.MaxForce = Vector3.new(400000000, 400000000, 400000000)
bodyVelocity.Velocity = attDistance.CFrame.Position*2
bodyVelocity.Name = 'jumpadLForce'
bodyVelocity.Parent = HRP
task.wait(0.1)
bodyVelocity:Destroy()
Att0:Destroy()
debounce = false
end)
end
end
local function onTagJumpPad(tag)
tag.Touched:Connect(function(hit)
if (hit.Parent:FindFirstChild('Humanoid')~=nil) then
task.spawn(function()
local char = hit.Parent
local HRP = char:FindFirstChild('HumanoidRootPart')
local rayOrigin = hit.Parent.PrimaryPart.CFrame.Position
local rayDirection = tag.CFrame.Position - rayOrigin
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {hit.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
if raycastResult.Normal then
if (hit.Parent:FindFirstChild('Humanoid')~=nil) then
if CollectionService:HasTag(tag, 'Tag_JumpPad') then
onJumpPad(tag, hit)
end
end
end
end
end)
end
end)
end
--// Tag Check
for _, part in (CollectionService:GetTagged('Tag_JumpPad') do
onTagJumpPad(part)
part.Orientation = Vector3.new(0,0,0) --//(in case my dumb brain rotates one of them and have no clue why they arent working properly)
end
CollectionService:GetInstanceAddedSignal('Tag_JumpPad'):Connect(function(jumpad)
onTagJumpPad(jumpad)
jumpad.Orientation = Vector3.new(0,0,0) --//(in case my dumb brain rotates one of them and have no clue why they arent working properly)
end)
I’m very new at coding so if you see any issues do tell me, I would love to learn more.