So, I just don’t want it to keep putting the character into the ground.
As seen in the video.
Here is my script that works except that part.
local tool = script.Parent
local player = script.Parent.Parent.Parent
local char = player.Character
script.Parent.ActivatRemo.OnServerEvent:Connect(function(player)
if player.Character:FindFirstChild("Hug") then
player.Character.Hug.Value = false
print('false')
else
print('No h/ug')
end
end)
local TimeBeforeEscape = 5
local using = false
local set = false
local CanEscape = false
local Hug = script.Hug
local HandsOut = script.HandsOut
local function TouchedPart(human)
if human:FindFirstChild("Hug") then
if human:FindFirstChild("Hug").Value == true then
return false
end
end
if script.Parent.Parent:FindFirstChild("Hug") then
if script.Parent.Parent:FindFirstChild("Hug").Value == true then
return false
end
end
if not human:FindFirstChild("Hug") then
local Hug1 = Instance.new("BoolValue")
Hug1.Parent = human
Hug1.Name = 'Hug'
Hug1.Value = true
else
human.Hug.Value = true
end
if not script.Parent.Parent:FindFirstChild("Hug") then
local Hug1 = Instance.new("BoolValue")
Hug1.Parent = script.Parent.Parent
Hug1.Name = 'Hug'
Hug1.Value = true
else
script.Parent.Parent.Hug.Value = true
end
if using then
human.UpperTorso.Anchored = false
end
coroutine.resume(coroutine.create(function()
wait(TimeBeforeEscape)
CanEscape =true
end))
local dance1 = script.Parent.Parent.Humanoid:LoadAnimation(Hug)
dance1:Play()
dance1.Looped = true
local dance2 = human.Humanoid:LoadAnimation(Hug)
dance2:Play()
dance2.Looped = true
for _, object in pairs(human:GetChildren()) do
if object:IsA("MeshPart") or object:IsA("Part") or object:IsA("BasePart") then
object.Massless =true
end
end
coroutine.resume(coroutine.create(function()
script.Parent.Parent.Hug.Chagned:Connect(function()
if using == true then
script.Parent.Parent.Hug.Value = true
end
end)
end))
coroutine.resume(coroutine.create(function()
human.Hug.Changed:Connect(function()
if human.Hug.Value == false then
print('Is false')
if CanEscape == true then
using = false
player.Character.Hug.Value = false
human.Hug.Value = false
print('Ended')
else
if using == true then
human.Hug.Value = true
else
human.Hug.Value = false
end
end
end
end)
end))
while using and wait() do
if using == true then
if set == true then
else
set = true
human.Humanoid.WalkSpeed = 0
human.Humanoid.UseJumpPower = true
human.Humanoid.JumpPower = 1
wait(.2)
--human.UpperTorso.CFrame = script.Parent.Parent.UpperTorso.CFrame * CFrame.new( 0, 1, -2 )
human.UpperTorso.CFrame = player.Character.UpperTorso.CFrame * CFrame.new(0, .5, -1 ) * CFrame.fromEulerAnglesXYZ(0, math.rad(180), 0)
local weld = Instance.new("WeldConstraint")
weld.Parent = player.Character.UpperTorso
weld.Part0 = human.UpperTorso
weld.Part1 = player.Character.UpperTorso
wait(.3)
--human.HumanoidRootPart.Orientation = Vector3.new(0,-180,0)
end
else
dance1.Looped = false
dance1:Stop()
dance2.Looped = false
dance2:Stop()
human.Hug.Value = false
player.Character.Hug.Value = false
human.Humanoid.WalkSpeed = 16
human.Humanoid.JumpPower = 50
player.Character.UpperTorso.WeldConstraint:Destroy()
for _, object in pairs(human:GetChildren()) do
if object:IsA("MeshPart") or object:IsA("Part") or object:IsA("BasePart") then
object.Massless = false
end
end
set = false
print('reset')
end
end
end
tool.Equipped:Connect(function()
local animation = script:WaitForChild("HandsOut")
local humanoid = script.Parent.Parent:WaitForChild('Humanoid')
local dance = humanoid:LoadAnimation(animation)
dance:Play()
dance.Looped = true
local part = Instance.new("Part")
part.Size = Vector3.new(5, 4.999, 3)
part.CanCollide = false
part.Anchored = false
part.Transparency = 1
part.Position = script.Parent.Parent.HumanoidRootPart.Position
part.Orientation = Vector3.new(0, 0, 0)
part.Parent = workspace
local weld = Instance.new("WeldConstraint")
weld.Parent = script.Parent.Parent.HumanoidRootPart
weld.Part0 = part
weld.Part1 = script.Parent.Parent.HumanoidRootPart
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name == script.Parent.Parent.Name then
else
using = true
part:Destroy()
TouchedPart(hit.Parent)
end
end
end)
tool.Unequipped:Connect(function()
using = false
dance:Stop()
dance.Looped = false
part:Destroy()
weld:Destroy()
end)
end)