Hello fellow developers! I made a trash bin, which you can push. The system works by adding a Motor6D which connects the trash bin to the player’s character and replacing the default idle and walk animations. Then when the player “stops pushing” the Motor6D is destroyed and the animations are set back to default. I accidentally noticed that if I “stopped pushing” the trash bin while I wasn’t standing still and I jumped on top of it I would get pushed off.
-
What do you want to achieve?
The trash bin not to push players or other parts off. -
What is the issue? Include screenshots / videos if possible!
Video -
What solutions have you tried so far?
I’ve tried looking for solutions all over the internet, but couldn’t manage to find any.
Here is the function that is responsible for letting go of the trash bin.
function onRelease(player)
if isPushed.Value == true and cooldown == false then
cooldown = true
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animateScript = character:WaitForChild("Animate")
animateScript.walk.WalkAnim.AnimationId = defaultAnim3
animateScript.idle.Animation1.AnimationId = defaultAnim1
animateScript.idle.Animation2.AnimationId = defaultAnim2
for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
playingTracks:Stop(0)
end
firstMagnitude = humanoid.MoveDirection.Magnitude
if humanoid.MoveDirection.Magnitude > 0 then
defaultWalkAnimation = Instance.new("Animation")
defaultWalkAnimation.AnimationId = defaultAnim3
defaultWalkAnimationTrack = humanoid:LoadAnimation(defaultWalkAnimation)
defaultWalkAnimationTrack:Play()
defaultWalkAnimation:Destroy()
defaultWalkAnimation = nil
else
defaultIdleAnimation = Instance.new("Animation")
defaultIdleAnimation.AnimationId = defaultAnim1
defaultIdleAnimationTrack = humanoid:LoadAnimation(defaultIdleAnimation)
defaultIdleAnimationTrack:Play()
defaultIdleAnimation:Destroy()
defaultIdleAnimation = nil
end
animationPlaying = true
M6D:Destroy()
M6D = nil
humanoid.JumpPower = defaultJump
humanoid.WalkSpeed = defaultSpeed
script.Parent.Bottom.LeftWheel.Anchored = true
script.Parent.Bottom.LeftWheel.Orientation = Vector3.new(0, script.Parent.BodyAttach.Orientation.Y, script.Parent.BodyAttach.Orientation.Z)
proximity.Enabled = true
isPushed.Value = false
cooldown = false
while animationPlaying == true do
if humanoid.MoveDirection.Magnitude ~= firstMagnitude then
if defaultIdleAnimationTrack then
if defaultIdleAnimationTrack.IsPlaying == true then
defaultIdleAnimationTrack:Stop()
defaultIdleAnimationTrack = nil
animationPlaying = false
end
if defaultWalkAnimationTrack.IsPlaying == true then
if humanoid.MoveDirection.Magnitude == 0 then
defaultWalkAnimationTrack:Stop()
defaultWalkAnimationTrack = nil
animationPlaying = false
end
end
elseif defaultWalkAnimationTrack then
if humanoid.MoveDirection.Magnitude == 0 then
defaultWalkAnimationTrack:Stop()
defaultWalkAnimationTrack = nil
animationPlaying = false
end
end
end
wait(0.1)
end
end
end
I really have no idea how any part of this script could turn my trash bin into a conveyor, but I have a suspicion that it might do with anchoring the part while it’s moving.