For the dumbbell replica to align correctly with Motor6D and connect properly to the players RightHand it’s essential to make tweaks and follow recommended methods, in your script:
local BenchPressWeights = game.ServerStorage:WaitForChild(“BasicBenchPressWeights”)
local Prox = script.Parent
Prox.Triggered:Connect(function(player)
local character = player.Character
if not character then
return
end
local humanoid = character:WaitForChild("Humanoid")
local rightHand = character:FindFirstChild("RightHand")
if not rightHand then
return
end
-- Clone the dumbbell and position it in the right hand
local clone = BenchPressWeights:Clone()
clone.Parent = rightHand
-- Remove existing RightGrip and create a new Motor6D for proper positioning
local rightGrip = rightHand:FindFirstChild("RightGrip")
if rightGrip then
rightGrip:Destroy()
end
local Motor6D = Instance.new("Motor6D", rightHand)
Motor6D.Name = "BenchpressMotor6D"
Motor6D.Part0 = rightHand
Motor6D.Part1 = clone.Handle
Motor6D.C0 = CFrame.new(-1.6, 0, 0.03) -- Adjust this position as needed
Im using a seat for this and i have 2 scripts inside of the ProximityPrompt, this script and another one for the player to be able to use a ProxPrompt to sit. How could i make it so the Weights deletes once the player leaves the seat? this may be a bit tricky to get done
local Prox = script.Parent
local Seat = Prox.Parent
local function HandleOccupancyChange()
Prox.Enabled = not Seat.Occupant
end
Seat:GetPropertyChangedSignal("Occupant"):Connect(HandleOccupancyChange)
local function HandleProximityTrigger(player)
if player.Character and player.Character.Humanoid then
Seat:Sit(player.Character.Humanoid)
end
end
Prox.Triggered:Connect(HandleProximityTrigger)
The provided script manages interaction with a seat using a ProximityPrompt. It ensures the ProximityPrompt is enabled or disabled based on whether the seat is occupied (Seat.Occupant). When a player triggers the ProximityPrompt, the script checks if the player has a character (Character) with a Humanoid, and if so, it makes the character sit in the seat (Seat:Sit(player.Character.Humanoid)). This allows smooth and effective interaction with the seat in the game.
( So the script is well structured and designed )