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

How to remove a proximity prompt attached to player humanoidrootpart?

Asked by 1 year ago
Edited 1 year ago

This is not my script but as you can see on the script " c.HumanoidRootPart.ProximityPrompt:Destroy()" is present. The original code in this part is "ProximityPrompt:Destroy()" but still wont work.

what I want to you to fix is that, if the player was revived then proximity prompt will be remove

game.Players.PlayerAdded:Connect(function(p)

    p.CharacterAdded:Connect(function(c)

        c:WaitForChild("Humanoid").HealthChanged:Connect(function(health)

            if health <= 1 and not c:FindFirstChild("Revived") then 

                c.Humanoid.MaxHealth = math.huge
                c.Humanoid.Health = math.huge

                c.HumanoidRootPart.Anchored = true


                local proximityPrompt = Instance.new("ProximityPrompt")
                proximityPrompt.HoldDuration = 5
                proximityPrompt.ActionText = "Hold E to Revive"
                proximityPrompt.ObjectText = c.Name .. "'s corpse"
                proximityPrompt.RequiresLineOfSight = false
                proximityPrompt.Parent = c.HumanoidRootPart

                game.ReplicatedStorage:WaitForChild("ReviveRE"):FireClient(p, proximityPrompt)


                proximityPrompt.Triggered:Connect(function(plr)

                    local revived = Instance.new("BoolValue", c)
                    revived.Name = "Revived"

                    c.Humanoid.MaxHealth = 100
                    c.Humanoid.Health = c.Humanoid.MaxHealth
                    c.HumanoidRootPart.Anchored = false

                    proximityPrompt.Enabled = false
                    c.HumanoidRootPart.ProximityPrompt:Destroy()

                    game.ReplicatedStorage:WaitForChild("ReviveRE"):FireClient(p)
                end)


                wait(60)

                if not c:FindFirstChild("Revived") then

                    local revived = Instance.new("BoolValue", c)
                    revived.Name = "Revived"

                    c.Humanoid.Health = 0
                end
            end
        end)
    end)
end)

Answer this question