I’m trying to make the character reset the state to normal when I leave the bench however when I teleport the player outside the bench it does a weird shape with his leg like V form and the character struggle to stand on even tho I want to be able to move after I quitted the bench so I don’t understand my issue and the arm also have issue
That animation that does the bench press looks like it might be getting called multiple times instead of once. And then it looks like you just jump right back out unintentionally, am I correct?
You mean like I maybe forgot to disconnect the event of the animation ?
It looks like when the humanoid enters Running state, the weird position goes away.
Maybe do
wait()
humanoid:ChangeState(Enum.HumanoidStateType.Running)
after releasing the character.
uhm try disabling or enabling some humanoid states when getting up
Here’s the server code for the animation I made a module script to organize code
local ClickDetector = script.Parent["BenchPress Bar"].SittingPart.ClickDetector
local Bar = script.Parent["BenchPress Bar"].Bar
local SittingPart = script.Parent["BenchPress Bar"].SittingPart
local AnimationModule = require(game:GetService("ReplicatedStorage").AnimationManager)
local CurrentPlayer = nil
local CallbackHandler = nil
local BenchWorkoutModule = require(game:GetService("ReplicatedStorage").WorkoutManager.BenchManager)
local AnimTrack
local Weld = nil
local TeleportPart = script.Parent.TeleportPart
function StandupFromBed(playerCharacter)
if playerCharacter ~= nil and script.Parent["BenchPress Bar"].SittingPart:FindFirstChild("Weld") then
script.Parent.BenchOwner.Value = nil
ClickDetector.MaxActivationDistance = 15
for _,anim in pairs(playerCharacter.Humanoid:GetPlayingAnimationTracks()) do
anim:Stop()
end
print(playerCharacter)
playerCharacter.Humanoid.PlatformStand = false
playerCharacter.RightUpperArm.CFrame = script.Parent["BenchPress Bar"].SittingPart.CFrame * CFrame.Angles(0, math.rad(180), 0) + Vector3.new(0, -5, 0)
playerCharacter.HumanoidRootPart.CFrame = script.Parent["BenchPress Bar"].SittingPart.CFrame * CFrame.Angles(0, math.rad(180), 0) + Vector3.new(0, 5, 0)
playerCharacter.HumanoidRootPart.Anchored = true
wait(0.1)
playerCharacter.HumanoidRootPart.Anchored = false
playerCharacter = nil
end
end
ClickDetector.MouseClick:Connect(function(player)
CurrentPlayer = game.Workspace:FindFirstChild(player.Name)
local BenchScript = CurrentPlayer.BenchPress
ClickDetector.MaxActivationDistance = 0
print("PLAYER CLICKED THE BENCH PRESS BAR")
AnimTrack = AnimationModule:BasicPose(CurrentPlayer, AnimationModule.Bench.Id)
Weld = BenchWorkoutModule:SitBench(CurrentPlayer, SittingPart)
game.ReplicatedStorage.CharacterAction.BenchPress:FireClient(player, player)
CallbackHandler = CurrentPlayer.Humanoid.Changed:Connect(function(property)
if CurrentPlayer ~= nil and property == 'Jump' then
BenchWorkoutModule:ExitBench(player)
AnimationModule:KillAnimation(AnimTrack)
Weld:Remove()
local WeldTeleport = Instance.new("Weld", TeleportPart)
WeldTeleport.Part0 = TeleportPart
WeldTeleport.Part1 = CurrentPlayer.HumanoidRootPart
local CloneBenchPress = CurrentPlayer.BenchPress:Clone()
CloneBenchPress.Parent = CurrentPlayer
CurrentPlayer.BenchPress:Destroy()
StandupFromBed(player.Character)
ClickDetector.MaxActivationDistance = 15
task.wait(0.5)
WeldTeleport:Remove()
end
end)
end)
Where would you think I would put it in my code ??
Wonder if it’s the animation or a weld that is causing like the humanoid to be anchored
dont need to anchor the root part, replace it with disabling falling down state and enabling getting up state in humanoid.
How would I do this with code like this
CurrentPlayer.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
wait(0.5)
CurrentPlayer.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
CurrentPlayer.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
wait(0.5)
CurrentPlayer.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
nope same issue have to fix something on jump property
my apology I’m new here
just do it once
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
revert the limbs motors i can see theyre wrongly positioned after getting up
limb motors which one are you talking about humanoid root part ? No it does that because of animation thing I think in nowhere in the code I changed limbs coordinate. The problem is I have to kill animation fast because it forms the V-shape with the animation base form when it’s sitting on the bench so if I don’t put this animation it doesn’t do the V-shape anymore so the problem lies somewhere in killing the animation and disabling animation state
Alright I removed the animation just to try returning back to idle state it seems there’s an interval between the state coming back to normal
BenchModule
local BenchManager = {
WeightSystem = {
"0.5", "1", "1.5", "2", "2.5", "5", "10", "15", "20", "25"
},
weights = {},
MAX_WEIGHT_POSSIBLE = 25
}
function BenchManager:SetOwner(bench, player)
bench.BenchOwner.Value = player
end
function BenchManager:ExitBench(player)
game.ReplicatedStorage.UnbindAction.UnbindBench:FireClient(player, player)
end
function BenchManager:SitBench(CurrentPlayer, sittingPart)
local Weld = Instance.new("Weld", sittingPart)
Weld.Part0 = sittingPart
Weld.Part1 = CurrentPlayer.HumanoidRootPart
Weld.C0 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(0), math.rad(-90))
return Weld
end
AnimationModule
local AnimationManager = {
["Bench"] = {
Id = 15950347027
},
["BicepCurl"] = {
Id = 15738821720
}
}
function AnimationManager:InitAnimation(animationId)
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=" .. animationId
return animation
end
function AnimationManager:BasicPose(humanoidModel, animationId)
local animation = self:InitAnimation(animationId)
local animTrack = humanoidModel:FindFirstChild("Humanoid").Animator:LoadAnimation(animation)
animTrack.Priority = Enum.AnimationPriority.Action
animTrack:Play()
animTrack:AdjustSpeed(0)
return animTrack
end
function AnimationManager:PlayAnimation(humanoidModel, animationId)
local animTrack = self:BasicPose(humanoidModel, animationId)
animTrack:Play()
animTrack.Priority = Enum.AnimationPriority.Action2
wait(animTrack.Length)
end
function AnimationManager:KillAnimation(animTrack)
print("ANIMATION SHOULD BE KILLED")
animTrack.TimePosition = 0
animTrack:Stop(0)
animTrack = nil
end
return AnimationManager
Rip I guess the tread is dying
Nevermind I come out with a solution on my own
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.