#Attaching barbell in a animation i need help
1 messages · Page 1 of 1 (latest)
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
can someone please help me
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
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
so yea thats my end goal can you help me?
have a barbell model in replicated storage (I would suggest making the part that should be held the PrimaryPart) and have a bench with a seat, have proximity prompt in the seat and have a script child to the prompt, and do the function Script.parent.Triggered:connect(funtion(plr))
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
Ty ill try
or you could instead of cloning a model just make a tool equip when the proximity prompt is triggered
Ill see which one works first
** You are now Level 1! **
they both will work the first one is a little advanced tho, the only difference is if you do the second method any Click detectors wont work when they are on the bench