Velocities, detecting them, and checking how large they are

it does im not only fairly certain of it but it worked earlier

like the code was still broken but broken to the point where it killed the player when it touched them

1 Like

You might want to switch the .Touched to the projectile/part.

well it just fell straight through the world and through the player

Yeah of course it will, if it doesn’t have any velocity from BodyMovers or anything like that, it will just fall down.

wait

wait you cant have a variable for a property can you

What exactly do you mean? {30_chars}

i mean im saying it fell through the world without killing the player so i assume thats not our issue

i have a variable (vel) for the assemblylinearvelocity of our part, and you cant have a variable for a property right…?

i changed it and it didnt do anything tho so

You can initialize variable with anything. What did you exactly change?

i just removed the variable “vel” and replaced it with just part.AssemblyLinearVelocity and all that

also new development…? i just rewrote the code to be like this

local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

character:WaitForChild("Humanoid").Touched:Connect(function(touchedPart, bodyPart)
		game.Players.LocalPlayer.Character.Humanoid.Health = 0
end)

and it killed the player everytime they spawned (as it should) so it must be an issue with the if statement…

i gtg briefly

Wait so if I understand this right. You want to kill the player only when the part has Velocity bigger than 50? If yes, could you tell me how are you testing the part flying into the player?

Alright, I tested it in my own studio and everything works for me. You might be testing it wrong. I tested that when the part is Collidable it will decrease the velocity when hit and .Touched will detect the decreased one which will be most of the time under 50.

LocalScript inside StarterCharacter:

local char = script.Parent

char.Humanoid.Touched:connect(function(part)
	local mag = part.AssemblyLinearVelocity.Magnitude
	
	if(mag>50) then
		char.Humanoid.Health = 0
	end
end)
  1. so is this basically just my script but simplified a bit more

so what does this mean im getting inaccurate results? i want the flying objects to be collidable so

Well then you have to calculate with the velocity slowing down. And yes, it is your script but more simplified.

1 Like