Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player doesnt take damage on .Touched:Connect()?

Asked by 3 years ago

trying to get the player to take damage when touching the explosion but the .Touched doesnt work, its at the bottom of the script after the animation. I dont know what the problem is but i get a feeling its the Tweening because i know you cant use .Touched on a tweening CFrame object. but these arent tweening CFrame theyre tweening Size

local RS = game:GetService("ReplicatedStorage")
local Nuke = script.Parent:WaitForChild("NukeE")

Nuke.OnServerEvent:Connect(function(Player,Action)
    local Damage = 1

    local Char = Player.Character
    local Hum = Char:WaitForChild("Humanoid")
    local HumRP = Char:WaitForChild("HumanoidRootPart")

    local Anims = script:WaitForChild("Animations")
    local Sounds = script:WaitForChild("Sounds")
    local Meshes = script:WaitForChild("Meshes")

    local Incoming = Hum:LoadAnimation(Anims:WaitForChild("Raise"))

    local Debris = game:GetService("Debris")
    local TweenService = game:GetService("TweenService")

    local effectsFold = Instance.new("Folder",workspace)
    effectsFold.Name = Player.Name.." Effects"
    Debris:AddItem(effectsFold,30)

    Hum.WalkSpeed = 0
    Hum.JumpPower = 0

    local Ring = Meshes:WaitForChild("Ring"):Clone()
    Ring.CFrame = HumRP.CFrame * CFrame.new(0,-2,0)
    Ring.Size = Vector3.new(6,0.15,6)
    Ring.Parent = effectsFold

    local Ring2 = Meshes:WaitForChild("Ring"):Clone()
    Ring2.CFrame = HumRP.CFrame * CFrame.new(0,-2,0)
    Ring2.Size = Vector3.new(8,0.15,8)
    Ring2.Parent = effectsFold

    local Ring3 = Meshes:WaitForChild("Ring"):Clone()
    Ring3.CFrame = HumRP.CFrame * CFrame.new(0,-2,0)
    Ring3.Size = Vector3.new(10,0.15,10)
    Ring3.Parent = effectsFold

    local Rgoal = {}
    Rgoal.Position = Ring.Position + Vector3.new(0,16,0)
    local Rinfo = TweenInfo.new(1)
    local Rtween = TweenService:Create(Ring,Rinfo,Rgoal)
    Rtween:Play()

    wait(0.2)

    local R2goal = {}
    R2goal.Position = Ring2.Position + Vector3.new(0,14,0)
    local R2info = TweenInfo.new(1)
    local R2tween = TweenService:Create(Ring2,R2info,R2goal)
    R2tween:Play()

    wait(0.2)

    local R3goal = {}
    R3goal.Position = Ring3.Position + Vector3.new(0,12,0)
    local R3info = TweenInfo.new(1)
    local R3tween = TweenService:Create(Ring3,R3info,R3goal)
    R3tween:Play()

    wait(1.4)

    local Rslam = {}
    Rslam.Position = Ring.Position + Vector3.new(0,-16.5,0)
    local RSinfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
    local RStween = TweenService:Create(Ring,RSinfo,Rslam)
    RStween:Play()

    wait(0.1)

    local R2slam = {}
    R2slam.Position = Ring2.Position + Vector3.new(0,-14.5,0)
    local RS2info = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
    local RS2tween = TweenService:Create(Ring2,RS2info,R2slam)
    RS2tween:Play()

    wait(0.1)

    local R3slam = {}
    R3slam.Position = Ring3.Position + Vector3.new(0,-12.5,0)
    local RS3info = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
    local RS3tween = TweenService:Create(Ring3,RS3info,R3slam)
    RS3tween:Play()

    local Explosion = Meshes:WaitForChild("FireBallExplode"):Clone()
    Explosion.CFrame = HumRP.CFrame * CFrame.new(0,0,0)
    Explosion.Size = Vector3.new(1,1,1)
    Explosion.Parent = effectsFold

    local Flare = Meshes:WaitForChild("Flare"):Clone()
    Flare.CFrame = HumRP.CFrame * CFrame.new(0,0,0)
    Flare.Size = Vector3.new(1.5,1.5,1.5)
    Flare.Parent = effectsFold

    local FlareRot = {}
    FlareRot.Orientation = Flare.Orientation + Vector3.new(0,9999999,0)
    local FRinfo = TweenInfo.new(30, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
    local FRtween = TweenService:Create(Flare,FRinfo,FlareRot)
    FRtween:Play()

    local Explode = {}
    Explode.Size = Explosion.Size + Vector3.new(250,250,250)
    local Einfo = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
    local Etween = TweenService:Create(Explosion,Einfo,Explode)
    Etween:Play()

    local FlareE = {}
    FlareE.Size = Flare.Size + Vector3.new(250.5,250.5,250.5)
    local Finfo = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
    local Ftween = TweenService:Create(Flare,Finfo,FlareE)
    Ftween:Play()

    Explosion.Touched:Connect(function(Hit)
        if Hit:IsA("BasePart") then
            if not Hit:IsDescendantOf(Char) then
                local Humanoid = Hit.Parent:FindFirstChild("Humanoid")

                if Humanoid then
                    if Humanoid.Health > 0 then
                        Humanoid:TakeDamage(Damage + Player.Attributes.Magic.Value)
                    end
                end
            end
        end
    end)

    Hum.WalkSpeed = 16
    Hum.JumpPower = 50

    wait(3)
    for i, v in pairs(effectsFold:GetChildren()) do
        local goal = {}
        goal.Transparency = v.Transparency + (1 - v.Transparency)
        local info = TweenInfo.new(1)
        local tween = TweenService:Create(v,info,goal)
        tween:Play()
        wait(0.1)
        Debris:AddItem(effectsFold,2)
    end
end)
0
Is the part Explosion's CanTouch property enabled? RAFA1608 543 — 3y
0
yes DraconianSG 58 — 3y
0
wait it wasnt let me try now DraconianSG 58 — 3y
0
still wont work DraconianSG 58 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

local Nuke = script.Parent:WaitForChild("NukeE") there's a typo I think. I might be wrong but Is it named "NukeE"?

Ad

Answer this question