hello there peoples in devforum, I have been having problem with making an script that is supposed to deal player who sat on a damage per second. and it uses bindableEvent functions for work, but however it does not work as intended yet.
I have used chatGPT and help from one other people from devforum, but it haven’t solved since. here is previous post I made that remains unsolved yet. the previous devforum post
also here is two script codes I’m currently using, this script belongs inside the seat.
--script inside seat that is supposed to fire an bindableEvent to damage player per second, and when player escape the seat, it is supposed to fire an another bindableEvent to stop dealing player damage per second.
local event = game.ServerStorage.PlayerDamagedPerSecond.Damage10PerSecondGrab
local stopevent = game.ServerStorage.PlayerDamagedPerSecond.StopDamage10PerSecondGrab
_G.timedamageonscreen = 4
cooldown = 14
DamageAmount = 11
debounce = true
script.Parent.Touched:Connect(function(plyr)
if debounce == true then
debounce = false
local person = plyr.Parent
if person:FindFirstChild("Humanoid") then
person:FindFirstChild("Humanoid").Health = person.Humanoid.Health - DamageAmount
local connection = script.Parent.Touched:Connect(function()
event:Fire()
if script.Parent.Occupant == false then
stopevent:Fire()
warn("Player escaped the grab, and stopevent that makes the grab stop damaging the player will fire.")
debounce = true
connection:Disconnect()
end
end)
end
end
end)
and this one is inside startercharacterscripts in my game, it also doesn’t work right now.
local event = game.ReplicatedStorage.PlayerDamagedPerSecond.Damage10PerSecondGrab
local stopevent = game.ReplicatedStorage.PlayerDamagedPerSecond.StopDamage10PerSecondGrab
local connection = event.Event:Connect(function()
game.Players.LocalPlayer.Humanoid.Health -= 10
wait(1)
repeat wait(0.1) until stopevent.Event:Connect(function()
connection:Disconnect()
end)
end)
I don’t know if anyone will discover this topic, but I post this for get help from peoples. thank you so much. -mari