#abomination code please help
1 messages · Page 1 of 1 (latest)
code:
local event = game:GetService("ReplicatedStorage").Events.Grab
local animation = game:GetService("ReplicatedStorage").Animations.Grab
local animation2 = game:GetService("ReplicatedStorage").Animations.Throw
local carrying = false
local userinputservice = game:GetService("UserInputService")
local hitbox = game:GetService("ReplicatedStorage").Hitboxes.Grab_Hitbox
--// GRAB EVENT \--
event.OnServerEvent:Connect(function(player, character, humanoid)
local character = player.Character
--// PLAYS ANIMATION & CREATES HITBOX \--
local new_hitbox = hitbox:Clone()
new_hitbox.Parent = workspace
new_hitbox.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0,0,-1.5)
task.delay(0.1, function()
new_hitbox:Destroy()
end)
new_hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= player.Name then
if carrying == false then
local animator = humanoid and humanoid:FindFirstChild("Animator")
local track = animator:LoadAnimation(animation)
track.Priority = Enum.AnimationPriority.Action
track:Play()
task.wait(0.5)
track:AdjustSpeed(0)
--// GRABS ENEMY PLAYER \\--
while hit do
if carrying == true then break
elseif carrying == false then
task.wait(0.1)
local success, err = pcall(function()
local enemy = hit.Parent
enemy.HumanoidRootPart.Orientation = Vector3.new(90, 90, 0)
enemy.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 5, 0) * CFrame.Angles(0,math.rad(180),0)
enemy.HumanoidRootPart.Anchored = true
enemy.Humanoid.AutoRotate = true
carrying = true
if new_hitbox then
new_hitbox:Destroy()
end
end)
if not success then
warn("Error: " .. err)
break
end
end
end
carrying = false
track:Stop()
end
end
end)
end)
event.OnServerEvent:Connect(function(player, character, humanoid)
if carrying == true then
local animator = humanoid and humanoid:FindFirstChild("Animator")
local track = animator:LoadAnimation(animation2)
track.Priority = Enum.AnimationPriority.Action
track:Play()
local new_hitbox1 = hitbox:Clone()
new_hitbox1.Parent = workspace
new_hitbox1.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0,5,0)
task.delay(0.1, function()
new_hitbox1:Destroy()
end)
--// TOUCH EVENT \\--
new_hitbox1.Touched:Connect(function(hit)
--// THROWS ENEMY PLAYER \\--
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= player.Name then
task.wait(0.1)
local success, err = pcall(function()
local enemy = hit.Parent
enemy.HumanoidRootPart.Anchored = false
enemy.Humanoid.AutoRotate = true
enemy.HumanoidRootPart.CFrame = enemy.HumanoidRootPart.CFrame * CFrame.new(0, 0, -20)
carrying = false
end)
if not success then
warn("Error: " .. err)
end
end
end)
end
end)
on wallahi im cooked ✌️
carrying is a single global boolean for ALL players
and you connect your onserverevent twice to the same remote
you anchor and teleoport every .1 seconds which isnt good
touched fires many times too
also codeblock next time its easier to read
alright thanks man