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

How do i make a die when you drink too much bloxy cola script? [closed]

Asked by
Hrugnir -5
3 years ago

i've been wondering though how to make one i can't think of one because i'm kind of new to scripting the die when you drink too much bloxy cola came to me when i played delicious consumables simulator

Closed as Not Constructive by lazycoolboy500 and imKirda

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

This is a server script and you'll need to put it into the tool. Btw this is an overcomplicated version and the lethalAmount variable is how many times the player has to drink before he dies. You can edit it to whatever value you would like it to be.

    local drinkCounter
local lethalAmount = 5

script.Parent.Equipped:Connect(function(player)
    if script.Parent.Parent:IsA("Model") then
        local character = workspace[script.Parent.Parent.Name]

        local playerCounter = Instance.new("IntValue", character)
        playerCounter.Name = script.Parent.Name
        drinkCounter = playerCounter
    else
        if script.Parent.Parent:IsA("Backpack") then
            local character = workspace[script.Parent.Parent.Parent.Name]

            local playerCounter = Instance.new("IntValue", character)
            playerCounter.Name = script.Parent.Name
            drinkCounter = playerCounter
        end
    end
end)

script.Parent.Activated:connect(function(player)
    drinkCounter.Value = drinkCounter.Value + 1

    if drinkCounter.Value == lethalAmount then
        if script.Parent.Parent:IsA("Model") then
            local character = workspace[script.Parent.Parent.Name]

            character.Humanoid.Health = 0
            drinkCounter.Value = 0
        else
            if script.Parent.Parent:IsA("Backpack") then
                local character = workspace[script.Parent.Parent.Parent.Name]

                character.Humanoid.Health = 0
                drinkCounter.Value = 0
            end
        end
    end
end)
Ad