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

A script that is suppose to drop a part in the players position when the die not working?

Asked by 4 years ago

This is my code, I cant figure out why it doesnt work. I get no errors, and it has never worked.

-- Variables:
    local Player = game.Players.LocalPlayer
    local Character = Player.Character
    local Humanoid = Character:WaitForChild("Humanoid")
    local Clone = game.Lighting.Button:Clone()
    local Torso = Character:WaitForChild("HumanoidRootPart")
    -- Main code:
    Humanoid.Health.Changed:Connect(function(health)
        if health == Humanoid.Health then
            if Humanoid.Health < 1 then
        Clone.Parent = workspace
        Clone.Position = CFrame.new(Torso.Cframe)
        wait(1)
        Clone.Anchored = true


            end
        end
        end)

2 answers

Log in to vote
0
Answered by 4 years ago
-- Variables:
    local Player = game:GetService("Players").LocalPlayer
    local Character = Player.Character
    local Humanoid = Character:WaitForChild("Humanoid")
    local Clone = game:GetService("Lightning").Button:Clone()
    local Torso = Character:WaitForChild("HumanoidRootPart")
    -- Main code:
        Humanoid.Died:Connect(function()
        Clone.Parent = workspace
        Clone.Position = CFrame.new(Torso.Cframe)
        wait(1)
        Clone.Anchored = true
        end)

if it doesnt work tell me

0
Doesnt work, this is suppose to be in a Local script right? zandefear4 90 — 4y
0
yeah and if you want it to replicate just tell me :) JasonkaranikYoutube 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try this if it does not work then tell me. Health is a property which cannot have events. You said Humanoid.Health.Changed but it needs to be Humanoid.HealthChanged


-- Variables: local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Clone = game.Lighting.Button:Clone() local Torso = Character:WaitForChild("HumanoidRootPart") -- Main code: Humanoid.HealthChanged:Connect(function(health) if Humanoid.Health < 1 then Clone.Parent = workspace Clone.Position = CFrame.new(Torso.Cframe) wait(1) Clone.Anchored = true end end)
0
Didnt work, sorry I didnt check for a while. zandefear4 90 — 4y
0
Wait a minute, there is a line saying (if health == Humanoid.Health then). Fun Fact this will almost never be true only if it is divisible by two. I edited the script and if you dont see the new script wait for couple minutes because of lag. 123nabilben123 499 — 4y
0
Also I updated my answer, please copy it and see if it works, it doesn't work because of the if statement logic. 123nabilben123 499 — 4y

Answer this question