#Need help at fixing death effect

5 messages · Page 1 of 1 (latest)

mental wharf
#

I have this local script inside StarterPlayerScripts. What it does is just show a death effect and a gui to respawn.
Some ppl will probably say that i should put it in StarterCharacterScripts, but the the black screen slowly fades in, and while u cant see anything, the character respawns, and when it respawns it fades in again. That's why i had to put it on StarterPlayerScripts.

It works good, but after the player dies once, if the player dies again, it will teleport to one of the spawn points and the effect won't play. It uses an event to respawn the player and because the script doesnt work anymore it also won't respawn the player.

I tried fixing this with a loop that will check when the character respawns and assign the character and humanoid again, but it still doesnt work. It does print out correctly tho.

The scripts are really long so it will be split on 2 messages (first being the client and second the server)

#

Client:

local Players = game:GetService("Players")
local TS = game:GetService("TweenService")

local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char.Humanoid

local hoverSound = game.SoundService.SoundEffects.hover
local clickSound = game.SoundService.SoundEffects.click


humanoid.BreakJointsOnDeath = false

local blurEffect = game.Lighting.HealthBlur
local colorEffect = game.Lighting.HealthColor
local stunSound = game.SoundService.SoundEffects.concussion
local respawnGui = plr.PlayerGui.Other.RespawnButton
local blackGui = plr.PlayerGui.BlackScreen.BlackScreen
local loadCharacterEvent = game.ReplicatedStorage.Events.ClientToServer:WaitForChild("LoadCharacter")
local ragdollEvent = game.ReplicatedStorage.Events.ClientToServer:WaitForChild("Ragdoll")

humanoid.Died:Connect(function()
    humanoid.PlatformStand = true
    print("blud died")
    ragdollEvent:FireServer(char)
    stunSound:Play()
    blurEffect.Size = 12
    colorEffect.TintColor = Color3.fromRGB(200, 100, 100)
    local tween = TS:Create(blurEffect,
        TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0.5, false),
        {Size = 50}
    )
    local tween2 = TS:Create(colorEffect,
        TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0.5, false),
        {TintColor = Color3.fromRGB(60, 30, 30)}
    )
    task.wait(1)
    tween:Play()
    tween2:Play()
    tween.Completed:Connect(function()
        print("uhh")
        task.wait(0.2)
        TS:Create(respawnGui,
            TweenInfo.new(.6, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out),
            {Size = UDim2.fromScale(0.3, 0.06)}
        ):Play()
        respawnGui.Visible = true

        respawnGui.MouseEnter:Connect(function()
            hoverSound:Play()
            TS:Create(respawnGui.UIStroke, TweenInfo.new(.2), {Color = Color3.fromRGB(200, 200, 200)}):Play()
        end)
        respawnGui.MouseLeave:Connect(function()
            TS:Create(respawnGui.UIStroke, TweenInfo.new(.2), {Color = Color3.fromRGB(12, 12, 12)}):Play()
        end)

        respawnGui.TextButton.MouseButton1Click:Connect(function()
            clickSound:Play()
            local tween = TS:Create(respawnGui,
                TweenInfo.new(.4, Enum.EasingStyle.Back, Enum.EasingDirection.In),
                {Size = UDim2.fromScale(0, 0)}
            )
            tween:Play()

            task.wait(.35)

            print("1")
            respawnGui.Visible = false
            blackGui.Transparency = 1
            blackGui.Visible = true
            TS:Create(blackGui, TweenInfo.new(2), {BackgroundTransparency = 0}):Play()
            task.wait(1.65)
            print("2")

            loadCharacterEvent:FireServer(plr)

            repeat task.wait() print("e") until workspace:FindFirstChild(plr.Name)
            char = workspace[plr.Name]
            humanoid = workspace[plr.Name]:WaitForChild("Humanoid")

            print(char.Name)
            print(humanoid.Parent.Name)

            task.wait(1)

            print("3")
            blurEffect.Size = 18
            local tween2 = TS:Create(blackGui, TweenInfo.new(2), {BackgroundTransparency = 1})
            local tween3 = TS:Create(blurEffect, TweenInfo.new(3), {Size = 0})
            tween2:Play()
            tween3:Play()

            tween2.Completed:Connect(function()
                print("4")
                blackGui.Visible = false
                blackGui.Transparency = 0
            end)

        end)
    end)
end)
#

Server:

loadCharacterEvent.OnServerEvent:Connect(function(player)
    player:LoadCharacter()
    local folder = RS.SpawnZones
    local children = folder:GetChildren()
    local rand = math.random(1, #children)
    player.Character:WaitForChild("HumanoidRootPart").Position = children[rand].Position
end)
#

Need help at fixing death effect

#

mispelled that