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

How to make something take damage over time?

Asked by
Choobu 59
6 years ago

How will i be able to make something that if a player like player1 touch player2. player2 will start taking damage over time and add like a button to activate for it to happen. If you can help me figure out what to do with this script i will be really happy :D. Well i already know how to get a button to activate it just only the touching and and damage over time

1 answer

Log in to vote
0
Answered by
xEiffel 280 Moderation Voter
6 years ago
Edited 6 years ago

I have classified a few things in the script that might be helpful to figure out what the script entirely does. I haven't tested this so I don't know if it works or not. Hopefully this is what you were wanting help with and don't hesitate to tell me if it doesn't work or a question about it.


settings = { --This is a table, this table will store all the variables that you can change. damageTime = 6, -- How many times It will damage the player inbetweenTime = .5, -- The time you have to wait until It damages again damage = 10, -- How much damage it will do debounce = false, -- Not recommended to change this } game.Players.PlayerAdded:Connect(function(playerWait) playerWait.CharacterAdded:Connect(function(characterWait) for i,v in pairs(game.Players:GetChildren()) do --[[ Grab all the players in the player service --]] repeat wait() until workspace:FindFirstChild(v.Name) workspace[v.Name].Touched:Connect(function(hit) --[[ This is a function which will fire when it is touched --]] if hit.Parent:FindFirstChildOfClass('Humanoid') then --[[ This will check if it hits something w/ a humanoid --]] if not settings.debounce then -- Checks if debounce is false settings.debounce = true for i = 1,settings.damageTime do -- This is a for loop that will loop a certain amount of times hit.Parent:FindFirstChildOfClass('Humanoid'):TakeDamage(settings.damage) --[[ this will take damage--]] wait(settings.inbetweenTime) -- this will wait for the time classified in settings. end settings.debounce = false end end end) end end) end)
0
k thanks :D Choobu 59 — 6y
0
for the 8 part i ahve to put a name in the brackets what if I want it to happen to everyone not just a certin player? Choobu 59 — 6y
0
let me modify the script with that xEiffel 280 — 6y
0
kk thanks Choobu 59 — 6y
View all comments (10 more)
0
okay modified. xEiffel 280 — 6y
0
If i added a wait.. Would it be right after part 14 as the time it will last for and then a wait after 16 for until u may be able to use it again? Choobu 59 — 6y
0
Ty so much I really never get this much help. Choobu 59 — 6y
0
All good and yes put a wait after line 16 for the length you want to wait until they can use it again and line 14 is the time it waits until it repeats the for loop, on line 12 is the amount of times it loops, but you can change the loop number in the settings table located at line 01. xEiffel 280 — 6y
0
kk thanks Choobu 59 — 6y
0
Could you put in the modified script changes into wherever you are storing your script, I made a mistake where there was a missing end and where It wouldn't work because the player hasn't been localised in the Workspace Service. xEiffel 280 — 6y
0
oh kk Choobu 59 — 6y
0
If i added the press certin key to use like e where would it be and what line will i use? Choobu 59 — 6y
0
Check your recent question I just answered it. xEiffel 280 — 6y
0
kk ty Choobu 59 — 6y
Ad

Answer this question