How to make an object "jump" if the player does?

hi, sorry i have no scripts or anything, but i have no idea on how to make what i want to achieve. what i want to do is make “jump” an object not welded to the player, as the player jumps. i don’t know if i was clear, let me know if not. thank you ^^

Could you use an attachment? Like parent the attachment to the character and the part to the attachment

basically i can’t weld anything because the player is inside this hollow ball (the object), and the player pushes the ball from inside to make it move, that’s why it needs to stay unattached from the player

What is this? These questions are not related to the topic

2 Likes

im not sure if this is what you’re looking for but…
also, not sure how this is performance wise

(StarterPlayer → StarterCharacterScripts)

-->> services
local runService = game:GetService("RunService")

-->> constants
local part = workspace:WaitForChild("Part") -- change to your part
local character = script.Parent

-->> functions, events
runService.RenderStepped:Connect(function ()
	local partCf = part.CFrame
	local primaryCf = character.PrimaryPart.CFrame
	local newCf = CFrame.new(partCf.X, primaryCf.Y, partCf.Z)
	
	part.CFrame = newCf * partCf.Rotation
end)
2 Likes

There are many ways you could do this, but what I’m thinking is you could just apply velocity to the part/primary part whenever the player jumps.

Something kind of like this should work (Make sure this is a LocalScript inside of StarterPlayer):

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()

local part = workspace.Part --change to your part



char:WaitForChild("Humanoid").Jumping:Connect(function(IsJumping)
	if IsJumping then
		workspace.Part.Velocity = Vector3.new(0,50,0)
	end
end)

Now obviously you could fire a remote event to make this show up on the server side as well, but this should get you started.

local Part = workspace:WaitForChild("Part")
local RunService = game:GetService("RunService")
local jumping = false
local yOffset = 0
local followPart

local function CharAdded(Char)
  local hum = Char:WaitForChild("Humanoid")
  hum.Jumping:Connect(function(bool)
    followPart = Char.PrimaryPart
    jumping = bool
    if jumping == true then
      yOffset = followPart.CFrame.Position.Y
    end
  end)
  hum.Died:Connect(function()
    jumping = false
  end)
end

RunService.Stepped:Connect(function(time, dt)
  if jumping then
    local pos = Part.CFrame.Position
    Part.CFrame = Part.CFrame + Vector3.new(0, followPart.X - pos.Y + yOffset, 0)
  end
end)

This should work client or server side.
You call the CharAdded(Player.Character) so it works with said player’s character. And you can do this for multiple parts if you modify this.