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

Why the .Touched stops working after a while?

Asked by
Necro_las 412 Moderation Voter
5 years ago
Edited 5 years ago

Context resumee:

  • I made an AnimationEvent guided skill that creates followed lightnings that fall in the mouse position.
  • These cloned lightnings has scripts that uses .Touched:Connect() to damage players.
  • The lightning spawned also creates a 3thrd spherical part that is the explosion in the ground before it vanishes.
  • These cloned explosions (spherical Parts that grows and fades out) has scripts that uses .Touched:Connect() to damage players.

Problem:

The Touched event in the explosions and in the lightning stops working after a while. The more I move my character or the mouse the sooner it stops working, or sometimes after the skill hits my own char.

Also, the skill has no script that makes it not to damage the player casting, but somehow it started behaving like this in some point of the development, I don't know if with this i'm facing a bug or if it is just some normal behavior of animation called events (wouldn't want it different though).

  • Local Script with the Player
01local UIS = game:GetService("UserInputService")
02local Players = game:GetService("Players")
03local player = Players.LocalPlayer
04local character = player.Character
05if not character then
06    character = game.Players.LocalPlayer.CharacterAdded:Wait()
07end
08local humanoid = character:WaitForChild("Humanoid")
09local mouse = player:GetMouse()
10local RemoteEvent = game.ReplicatedStorage.RemoteEvent
11-- storm:
12local StormCast = game.ReplicatedStorage.StormCast
13local StormCastTrack = humanoid:LoadAnimation(StormCast)
14local cooldown = false
15 
View all 64 lines...
  • Server Script:
01local RemoteEvent = game.ReplicatedStorage.RemoteEvent
02local StormCast = game.ReplicatedStorage.StormCast
03 
04 
05RemoteEvent.OnServerEvent:Connect(function(player, request, dado)
06 
07    if request == "SkyBlast" then
08        local character = player.Character
09        local SkyBlast = game.ReplicatedStorage.SkyBlast
10        local SkyBlast_CS = SkyBlast:Clone()
11        SkyBlast_CS.Name = "SkyBlast_CS"
12        SkyBlast_CS.Parent = game.Workspace
13        SkyBlast_CS.Position = Vector3.new(0,33,0)+ character.LowerTorso.Position
14    end
15 
View all 26 lines...
  • part of Server Script inside the Lightning (.touched damage and calls explosion):
01script.Parent.Touched:Connect(function(hit)
02    if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
03        debounce = true
04        hit.Parent.Humanoid:TakeDamage(5)
05        delay(0.3, function(bounce)debounce = false end)
06 
07    end
08end)
09 
10spawn(function(explodir)
11    local boomC = boom:Clone()
12    boomC.Parent = workspace
13    boomC.Position = raio.Position - Vector3.new(0,29,0)
14end)
  • part of the Server Script inside the explosion (.touched damage)
1script.Parent.Touched:Connect(function(hit)
2    if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
3        debounce = true
4        hit.Parent.Humanoid:TakeDamage(5)
5        delay(0.5, function(bounce)debounce = false end)
6    end
7end)
0
Nice answer layout. PrismaticFruits 842 — 5y

1 answer

Log in to vote
0
Answered by
donutgod -52
5 years ago

Explosions are not base parts and they can't fire a touch event if you touch them.

0
These what i call "explosions" are not the Instances called explosion, they are spherical parts that grows and fades out. Necro_las 412 — 5y
0
Maybe it has to do with the debounce. Try changing those. donutgod -52 — 5y
0
It isn't. I've checked if the event was firing before the code checks if debounce is true. Necro_las 412 — 5y
0
Regardless, explosions have an event called '.Hit'. GeneratedScript 740 — 5y
Ad

Answer this question