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

SOLVED how would drain a player's health with one script? (it takes 2)

Asked by 4 years ago
Edited 4 years ago

here is my code, it's in serverscriptservice. I have made this by myself. it works prefectly. You just need to tween the parts, that script is included

01local player = game:GetService('Players').PlayerAdded:Connect(function(player)
02local char = player.CharacterAdded:Connect(function(character)
03local hum = character:WaitForChild("Humanoid")
04    end)
05end)
06 
07local function DamageOverTime()
08local GasPart = game.Workspace.GasPart
09repeat wait() hum.Health = hum.Health - 0.05
10until
11    GasPart.TouchEnded 
12end        
13 
14for k,n in pairs(game.Workspace:GetChildren()) do
15    local player = game:GetService('Players').PlayerAdded:Connect(function(player)
View all 27 lines...

another script in serverscriptservice.

01local TweenService = game:GetService("TweenService")
02local Info = TweenInfo.new(
03        1,
04        Enum.EasingStyle.Linear,
05        Enum.EasingDirection.InOut,
06        -1,
07        true,
08        0  
09    )
10 
11    local Goals = {
12    Size = Vector3.new(11.56, 17.11, 27.11);
13    }
14 
15for k,n in pairs(game.Workspace:GetChildren()) do
View all 21 lines...

1 answer

Log in to vote
0
Answered by 4 years ago

Uhh The format is confusing me but I'll try to revise your script

01game.Players.PlayerAdded:Connect(function(player) -- just put into a whole thread  
02    local function DamageOverTime()
03        playing = true
04        local GasPart = game.Workspace.GasPart
05        repeat -- you do not need the while wait() do
06            wait(1)
07            hum.Health = hum.Health - 1
08        until hum.Health = 0 -- until hum.Died is invalid(i think)
09        GasPart.TouchEnded:Connect(function() -- touchended is an event, why the if statement?
10            print("the person has stopped touching me")
11        end)
12    end)
13    for k,n in pairs(game.Workspace:GetChildren() do
14        playing = false
15        if n.Name == "GasPart" and playing == false then
View all 21 lines...

Hope that helps

1
that doesn't work. astonplep 32 — 4y
0
oh rip sorry. im glad you figured it out tho. Omq_ItzJasmin 666 — 4y
Ad

Answer this question