Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

BodyPosition affect one person?

I'm trying to make it so when somethings hit body position only affects the person hit

	local function onTouched(hit)
		if hit.Parent ~= nil and hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent:FindFirstChild("Humanoid") ~= pchar.Humanoid and check == 0 then	
		new.Transparency = 0.4
		
		local qq = Instance.new("BodyPosition")	
		qq.Position = new.Position	
		qq.Parent = pchar["UpperTorso"]	
		qq.MaxForce = Vector3.new(1e8,1e8,1e8)
		qq.P = 100
		qq.D = 10
		debris:AddItem(qq,5)
		end
	end

I tried this but it sucks up everyone that's anywhere near it

6 comments

0

well first off, what is pchar?

0

I'm assuming that pchar is suppose to be the Player's Character. But where did you define it at? We need to know that in order to help you

0

yeah pchar is the local player

0

its defined at the top of the entire function so not in this function specifically

0

the if statement is designed so the player creating this isn't hit, which works but the player is affected by the body velocity created by the script as well as other players that aren't hit

0

the body position* sorry

1 answer

So after a while of messing around I finally figured out how to fix it (I also made the function more efficient)

local check = 0	
	hb.Touched:connect(function(hit)
	local ehum = hit.Parent:findFirstChild("UpperTorso")
		if hit.Parent ~= nil and hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent:FindFirstChild("Humanoid") ~= pchar.Humanoid and check == 0 then	
		new.Transparency = 0.4
		
		local qq = Instance.new("BodyPosition")	
		qq.Position = new.Position	
		qq.Parent = ehum
		qq.MaxForce = Vector3.new(1e8,1e8,1e8)
		qq.P = 100
		qq.D = 10
		debris:AddItem(qq,5)	
		end
	end)	

This works with R15 which is what "UpperTorso" is, if you're using r6 just do "Torso"

This discussion is preserved as it was. New answers, comments, and votes are closed.