I am a pretty new coder making a ball game where the point is basically that, if you dash into another player/ball they get killed. So to make the ball I took an R6 dummy and inserted a sphere part. But when i try to use the regular Touched nothing happens. I was thinking maybe the part I used in the dummy doesnt count as a bodypart? Because I kind of just made it barely bigger than the dummy and made all the other body parts uncollidable and totally transparent.
So what I wanna do is kind of
function (Touched) if ThePartThatTouched = Game.Workspace.Map then print ("Map") else print ("else") if ThePartThatTouched = NameOfTheSphereIUsedInTheDummy ThePartThatTouched:FindFirstChild("Humanoid").Health = 0 end end script.Parent.TouchesAnotherPart (Touched)
Thank you very much for reading!
You could name each sphere the same as a player's name and check if the part's name is that, if so, do stuff.
Use the Part.onTouched event.
YourPart.Touched:Connect(function(thePartThatHit) -- When YourPart is touched, run this function. Register the touching part as a variable called thePartThatHit. end)
If a character touches YourPart, for example, thePartThatHit would be a body part such as LeftArm, Head, Torso, etc. From here we can locate the humanoid, whose parent is the character model.
YourPart.Touched:Connect(function(thePartThatHit) local humanoid = thePartThatHit.Parent:FindFirstChildOfClass("Humanoid") if humanoid then -- Confirming if indeed a Humanoid exists. If there isn't a Humanoid this variable will be nil (nonexistent), the part that touched is probably not a character. If it does, then continue humanoid.Health = 0 -- Kills the humanoid end end)
Use the part:GetTouchingParts() function.
For example:
local Part = script.Parent local connection = Part.Touched:Connect(function() end) --This allows it to detect parts touching it even if they are for example anchored and intersecting with the part. local TouchingParts = part:GetTouchingParts() for key, TouchingPart in pairs (TouchingParts) do TouchingPart.Transparency = 1 --Do whatever you want to the TouchingPart variable to affect all parts touching the Part. end