Hey everyone,
I have a script that creates an arm-stretching effect where one player grabs another. When the grab connects, I play an animation where the grabber slams the target player to the ground.
The problem is that during this slam, the grabber player gets unexpectedly launched upwards, likely because the grabbed target’s collidable parts are pushing against the ground. I’ve tried making the grabbed player’s parts non-collidable during the slam, but it doesn’t seem to fix the issue.
Thanks for the help!
local tool = script.Parent
local event = tool:WaitForChild("ExtendArmEvent")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local ANIM_ID = 107663891431534
local WALK_SPEED = 16
local STRETCH_TIME = 0.1
local WAIT_AFTER_ATTACH = 1
local function disablePhysicsOnTarget(targetChar)
for _, part in ipairs(targetChar:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = false
part.CanTouch = false
part.CanQuery = false
end
end
local humanoid = targetChar:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.PlatformStand = true
humanoid.Sit = false
end
end
local function enablePhysicsOnTarget(targetChar)
for _, part in ipairs(targetChar:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = true
part.CanTouch = true
part.CanQuery = true
end
end
local humanoid = targetChar:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.PlatformStand = false
end
end
local function setCollisionForModel(model, canCollide)
for _, part in ipairs(model:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = canCollide
end
end
end
local function findCharacterModel(part)
local current = part
while current and not current:FindFirstChildOfClass("Humanoid") do
current = current.Parent
if not current or not current:IsA("Model") then
return nil
end
end
return current
end
event.OnServerEvent:Connect(function(player)
local char = player.Character
if not char then return end
local humanoid = char:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
local leftArm = char:FindFirstChild("Left Arm") or char:FindFirstChild("LeftLowerArm")
if not leftArm then return end
humanoid.WalkSpeed = 0
wait(0.4)
leftArm.Transparency = 1
for _, d in ipairs(leftArm:GetDescendants()) do
if d:IsA("Decal") or d:IsA("Texture") or d:IsA("Mesh") then
d.Transparency = 1
end
end
local armTemplate = ReplicatedStorage:WaitForChild("StretchyArmTemplate"):Clone()
armTemplate.Anchored = true
armTemplate.CanCollide = false
armTemplate.Parent = workspace
local originalCFrame = leftArm.CFrame
local originalSize = armTemplate.Size
local DOWN_OFFSET = Vector3.new(0, 0, 0)
armTemplate.CFrame = originalCFrame * CFrame.new(DOWN_OFFSET)
armTemplate.Size = originalSize
local newY = 10
local newSize = Vector3.new(originalSize.X, newY, originalSize.Z)
local downOffset = armTemplate.CFrame.UpVector * -((newY - originalSize.Y) / 2)
local targetCFrame = armTemplate.CFrame + downOffset
local tweenInfo = TweenInfo.new(STRETCH_TIME, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local sizeTween = TweenService:Create(armTemplate, tweenInfo, {Size = newSize})
local moveTween = TweenService:Create(armTemplate, tweenInfo, {CFrame = targetCFrame})
local armWeld
local targetWeld
local attachedTarget = nil
local targetAttached = false
local function onTouch(hit)
if targetAttached then return end
if not hit then return end
local hitCharacter = findCharacterModel(hit)
if not hitCharacter then return end
local hitHumanoid = hitCharacter:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitCharacter ~= char then
targetAttached = true
sizeTween:Cancel()
moveTween:Cancel()
disablePhysicsOnTarget(hitCharacter)
armWeld = Instance.new("Weld")
armWeld.Part0 = leftArm
armWeld.Part1 = armTemplate
armWeld.C0 = CFrame.new(0, -4, 0)
armWeld.C1 = CFrame.new()
armWeld.Parent = armTemplate
attachedTarget = hitCharacter
setCollisionForModel(attachedTarget, false)
local rootPart = attachedTarget:FindFirstChild("HumanoidRootPart") or attachedTarget.PrimaryPart or hit
targetWeld = Instance.new("Weld")
targetWeld.Part0 = armTemplate
targetWeld.Part1 = rootPart
targetWeld.C0 = CFrame.new(0, -newY/2, 0)
targetWeld.C1 = CFrame.new()
targetWeld.Parent = armTemplate
armTemplate.Anchored = false
local animator = humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", humanoid)
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://"..ANIM_ID
local animationTrack = animator:LoadAnimation(anim)
animationTrack.Priority = Enum.AnimationPriority.Action
animationTrack:Play()
delay(WAIT_AFTER_ATTACH, function()
animationTrack:Stop()
if attachedTarget then
enablePhysicsOnTarget(attachedTarget)
setCollisionForModel(attachedTarget, true)
attachedTarget = nil
end
if targetWeld then
targetWeld:Destroy()
targetWeld = nil
end
if armWeld then
armWeld:Destroy()
armWeld = nil
end
armTemplate.Anchored = true
local retractTween = TweenService:Create(armTemplate, tweenInfo, {
Size = originalSize,
CFrame = armTemplate.CFrame * CFrame.new(0, (newY - originalSize.Y) / 2, 0)
})
retractTween:Play()
retractTween.Completed:Wait()
armTemplate:Destroy()
leftArm.Transparency = 0
for _, d in ipairs(leftArm:GetDescendants()) do
if d:IsA("Decal") or d:IsA("Texture") or d:IsA("Mesh") then
d.Transparency = 0
end
end
humanoid.WalkSpeed = WALK_SPEED
end)
end
end
armTemplate.Touched:Connect(onTouch)
sizeTween:Play()
moveTween:Play()
sizeTween.Completed:Wait()
if not targetAttached then
wait(0.5)
armTemplate.Anchored = true
local retractTween = TweenService:Create(armTemplate, tweenInfo, {
Size = originalSize,
CFrame = armTemplate.CFrame * CFrame.new(0, (newY - originalSize.Y) / 2, 0)
})
retractTween:Play()
retractTween.Completed:Wait()
armTemplate:Destroy()
leftArm.Transparency = 0
for _, d in ipairs(leftArm:GetDescendants()) do
if d:IsA("Decal") or d:IsA("Texture") or d:IsA("Mesh") then
d.Transparency = 0
end
end
humanoid.WalkSpeed = WALK_SPEED
end
end)