#Attaching barbell in a animation i need help

1 messages · Page 1 of 1 (latest)

crimson stirrup
#

Im trying to attach a barbell in my bench animation but i cant seem to get it right

#

BenchScript =
-- Script in Bench2
local bench = script.Parent
local seat = bench:WaitForChild("BenchSeat")
local prompt = bench:WaitForChild("BenchPart"):WaitForChild("ProximityPrompt")

prompt.Triggered:Connect(function(player)
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
seat:Sit(humanoid)
end
end
end)

#

The rest of the script is StarterPlayer -> StarterPlayerScripts =

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local bench = workspace:WaitForChild("Bench2")
local seat = bench:WaitForChild("BenchSeat")

local remote = ReplicatedStorage:WaitForChild("BenchBarbellEvent")

-- Animatie
local animationId = "rbxassetid://93706828226014"
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local animTrack = humanoid:LoadAnimation(animation)

local sitting = false
local cooldown = false

-- Check of speler in seat zit
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local occupant = seat.Occupant
if occupant and occupant.Parent == character then
sitting = true
else
sitting = false
if animTrack.IsPlaying then
animTrack:Stop()
end
-- Barbell loslaten als speler uitstapt
remote:FireServer("Detach")
end
end)

-- Klik om animatie af te spelen
player:GetMouse().Button1Down:Connect(function()
if sitting and not cooldown then
animTrack:Play()
remote:FireServer("Attach") -- 🔹 stuur signaal: pak barbell
cooldown = true
task.delay(5, function()
cooldown = false
end)
end
end)

-- Spatie om eruit te gaan, alleen als animatie klaar is
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space and sitting and not animTrack.IsPlaying then
seat:Sit(nil)
remote:FireServer("Detach") -- 🔹 stuur signaal: leg barbell terug
end
end)

#

Attaching barbell in a animation i need help

crimson stirrup
#

can someone please help me

polar glacier
#

what is your end goal? if you want the player to be holding a barbell while doing the animation you just weld a barbell to the players hand

crimson stirrup
#

my end goal is when you press E you go on the seat and then the barbell should be welded to the hand(R6) and when you click and it does the rep animation it should just go with the animation and when i leave the bench with space it should spawn back in the rack

#

but i cant seem to do it

crimson stirrup
polar glacier
#

in that script you are going to Clone the barbell and create a weld that is childed to the barbell, set Part0 to the PrimaryPart of the barbell and Part1 to the players hand

#

you are then gonna need to mess with the CFrame rotation of the part because it will place oddly

polar glacier
#

or you could instead of cloning a model just make a tool equip when the proximity prompt is triggered

crimson stirrup
#

Ill see which one works first

hardy martenBOT
#

studio** You are now Level 1! **studio

polar glacier
crimson stirrup
#

Oh then i have to do the first

#

Cuz the animation works with clicks