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

Why does this not move the other player to the sphere?

Asked by 8 years ago
if key=='f' and almost then
            almost=false
            going=false
            starting=false
            table.foreach(script.Parent:GetChildren(),
                function(i,v)
                if v.ClassName~='LocalScript' and v.ClassName~='Weld' then
                    v.Transparency=1
                end
            end)
            loadsuck:Play()
            wait(.4)
            local sphere=Instance.new('Part',game.Workspace)
            sphere.Size=Vector3.new(2,2,2)
            sphere.Transparency=.5
            sphere.BrickColor=BrickColor.new('Really black')
            sphere.Shape='Ball'
            sphere.Anchored=true
            sphere.CanCollide=false
            sphere.Position=Vector3.new(character.Torso.Position.X,character.Torso.Position.Y,character.Torso.Position.Z)
            cantakedamage=true
            table.foreach(game.Players:GetChildren(),
                function(i,v)
                local distance=(v.Character.Torso.Position-sphere.Position).magnitude
                if distance<=20 and cantakedamage and not taken then
                    taken=true
                    if v.Name~=character.Name then
                        body=Instance.new('BodyPosition',v.Character.Torso)
                        body.MaxForce=Vector3.new(100000,100000,100000)
                        body.Position=sphere.Position
                        if v.Character.Humanoid.Health<=0 and body~=nil then
                            body:remove()
                            cantakedamage=false
                            taken=false
                            xp.Value=xp.Value+1
                        end
                    end
                end
            end)
            wait(10)
            done=true
            sphere:remove()
            body:remove()
            cantakedamage=false
            taken=false
            table.foreach(script.Parent:GetChildren(),
                function(i,v)
                if v.ClassName~='LocalScript' and v.ClassName~='Weld' then
                    v.Transparency=0
                end
            end)
        end

When i remove the if v.Name~=character.Name then it works where as if i keep it, it doesnt work. I have tried this will other people so...

Answer this question