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

BodyPosition affect one person?

Asked by 6 years ago
Edited 6 years ago

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

0
well first off, what is pchar? CreeperAssassin005 30 — 6y
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 soutpansa 120 — 6y
0
yeah pchar is the local player DeviantProphet 50 — 6y
0
its defined at the top of the entire function so not in this function specifically DeviantProphet 50 — 6y
View all comments (2 more)
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 DeviantProphet 50 — 6y
0
the body position* sorry DeviantProphet 50 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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"

Ad

Answer this question