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
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)