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
01 | local player = game:GetService( 'Players' ).PlayerAdded:Connect( function (player) |
02 | local char = player.CharacterAdded:Connect( function (character) |
03 | local hum = character:WaitForChild( "Humanoid" ) |
07 | local function DamageOverTime() |
08 | local GasPart = game.Workspace.GasPart |
09 | repeat wait() hum.Health = hum.Health - 0.05 |
14 | for k,n in pairs (game.Workspace:GetChildren()) do |
15 | local player = game:GetService( 'Players' ).PlayerAdded:Connect( function (player) |
16 | local char = player.CharacterAdded:Connect( function (character) |
17 | hum = character:WaitForChild( "Humanoid" ) |
20 | local GasPart = game.Workspace.GasPart |
22 | if n.Name = = "GasPart" then |
24 | n.Touched:Connect(DamageOverTime) |
another script in serverscriptservice.
01 | local TweenService = game:GetService( "TweenService" ) |
02 | local Info = TweenInfo.new( |
04 | Enum.EasingStyle.Linear, |
05 | Enum.EasingDirection.InOut, |
12 | Size = Vector 3. new( 11.56 , 17.11 , 27.11 ); |
15 | for k,n in pairs (game.Workspace:GetChildren()) do |
17 | if n.Name = = "GasPart" then |
18 | local exampletween = TweenService:Create(n, Info, Goals) |