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

How to fix/replace .touched event not firing???

Asked by 6 years ago
Edited 6 years ago

I made a boomerang ability for a scythe I made. There is a touched event connected to the blade of the scythe. However, whenever I throw it, it sometimes triggers the touched event and sometimes it does not trigger the touched event. The only thing that is in the touched event is just a print statement so I am notified if the touched event even fires up. At certain angles, the touched event refuses to fire. The blade is a union operation so I have already tinkered with collision settings. All of the settings always result in that sometimes random wacky zany moment where it just doesn't trigger the touched event. The ability itself is an animation; a motor6d is the link between my right hand and the scythe's handle. The blade is non-collidable. However, I have tried setting it to CanCollide to see the results. Whenever it landed, it flung me because it is set to CanCollide. The main surprise was the fact that sometimes it just phased through the dummy even though the scythe and the target are set to CanCollide. I even started putting up invisible boxes around the scythe's blade and a box around the dummy but still no luck. I have stressed out so many options that I believe I am going insane...I've been trying to find a solution for about 2 weeks. At this point, ya fellas are the only shot I got left. Here is a clip of the problem (in the clip the scythe blade is non-collidable and has its collision fidelity set to hull): https://www.youtube.com/watch?v=N1m5JH0Q2ww

The script is literally just:

script.Parent.Blade.Touched:Connect(function(bee)
print("jesus christ just work")
game.ReplicatedStorage.DamageEvent:FireServer(power, bee, ability, currentCD)
end
0
Put the script you tried to make, and see this: https://scriptinghelpers.org/help/how-post-good-questions-answers yHasteeD 1819 — 6y
0
it isnt the script...its the bloody fact that .touched isn't triggering for some reason...if anyone can tell me a substitute/concept to replace the touched event then papa bless. 9ghostman9 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

.Touched does not work on local scripts. You need to use .Touched on server scripts. Use:

--//ServerScript

script.Parent.Blade.Touched:Connect(function(bee)
print("jesus christ just work")
game.ReplicatedStorage.DamageEvent:FireClient(power, bee, ability, currentCD)
end)

Server scripts already fire the server so you have to use :FireClient() instead of :FireServer()

--//LocalScript

game.ReplicatedStorage.DamageEvent.OnClientEvent:Connect(function(AnyArgumentsHere)
-- Anything you want to activate here
end)

Also when doing functions, make sure you put "end)" and not "end" on line 4 you put end. Just letting you know. Try this and it should work.

if you don't want your script to be client only then do this:

--//ServerScript
script.Parent.Blade.Touched:Connect(function(bee)
print("jesus christ just work")
--Anything you want to activate here
end)

Hope this helps :)

0
Thanks for catching the error with the end). I can't believe I forgot such a simple thing...However, it still doesn't work sometimes. At certain angles, the scythe will just pass through the dummy and the touched event won't fire even in a server script. 9ghostman9 0 — 6y
Ad

Answer this question