Hello,
I’m currently creating an obby game in which players walk on a ball:
[Like that]
The existing script successfully allows players to walk on the ball “without any issues”, thanks to the implementation of a Vector Force downside to prevent the player and the ball from ascending. However, I have encountered a few challenges related to the jumping mechanics:
Whenever the player jumps, they jump way too high
Furthermore, it goes back to the ground wayyyy too slowly and takes several seconds,
and finally, players can jump infinitely.
I would need the player to jump normally, like if they were jumping from the ground with normal physics.
Here’s the script so far:
local ballRoot = script.Parent
local connection
local cooldown = false
game:GetService("Players").PlayerAdded:Connect(function(plr)
if ballRoot:FindFirstChild("PlayerWeld") then
return
end
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidDescription = game:GetService("Players"):GetHumanoidDescriptionFromOutfitId(plr.UserId)
humanoidDescription.WalkAnimation = "16565961810"
-- humanoid:ApplyDescription(humanoidDescription)
if ballRoot:FindFirstChild("PlayerWeld") then
return
end
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
if humanoidRootPart and humanoid then
-- humanoidRootPart.Anchored = true
local height = ballRoot.Size.Y / 2 + humanoid.HipHeight + humanoidRootPart.Size.Y / 2 + 3.3
print(height)
character:PivotTo(CFrame.new(ballRoot.Position + Vector3.new(0, height, 0)))
local weld = Instance.new("WeldConstraint")
weld.Name = "PlayerWeld"
weld.Part0 = humanoidRootPart
weld.Part1 = ballRoot
weld.Parent = ballRoot
humanoidRootPart.Massless = true
humanoidRootPart.Anchored = false
connection = humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if not humanoid:GetState(Enum.HumanoidStateType.Jumping) and not cooldown then
weld:Destroy()
ballRoot.Prompt.Enabled = true
cooldown = true
task.wait(2)
cooldown = false
end
end)
end
end)
I tried to add a cooldown system and to change properties but I can’t figure out a way to fix this. I’d be happy if anyone could help me, thanks!