deadlift.OnServerEvent:Connect(function(Player, barOccupied)
local minimum = 10
local bar = game.Workspace["Phase 1"].GymEquipment.Benchpress.deadlift_barbell.BenchpressBar
local weight1 = game.Workspace["Phase 1"].GymEquipment.Benchpress.deadlift_barbell.fortyFive
local weight2 = game.Workspace["Phase 1"].GymEquipment.Benchpress.deadlift_barbell.fortyFive2
local owner = Player.Owner
if Player.leaderstats.Energy.Value > 0 and Player.leaderstats.Energy.Value >= minimum then
Player.leaderstats.Energy.Value -= 10
Player.leaderstats.Strength.Value += 10
RunService.Heartbeat:Connect(function()
if barOccupied.Value == true and owner.Value == true then
bar.Position = (Player.Character.LeftHand.Position + Player.Character.RightHand.Position) / 2
print(Player.Name)
weight1.Position = bar.Position + Vector3.new(-2.85,0,0)
weight2.Position = bar.Position + Vector3.new(2.85,0,0)
end
end)
end
end)
(Server script)
The bar is following the first player who gets on and also the second player at the same time even when the first player is off the bar.
How can I get the object to follow only the player who is using the bar?
#Edit
Here’s what’s happening, when Player1 hops on the deadlift bar by pressing F, the deadlift bar follows Player1’s hands. Then when Player2 gets on the bar, the bar goes back and follows Player1’s hands. How can I make it to where the bar follows the player’s hands only when they are on the deadlift?