I need help with making this script affect the torso of the character, instead of a random part.
What I'm trying to do, is this https://twitter.com/egomoose/status/740277001244774400
This script below does the same, but to a part created by an instance. Help?
Trying to make this script do the same thing as...
local mouse = game.Players.LocalPlayer:GetMouse()
local moveModel = game.Players.LocalPlayer.Character;
-- don't detect the model we're moving
mouse.TargetFilter = moveModel
local c = moveModel;
local hrp = c:WaitForChild("HumanoidRootPart")
local j = hrp:WaitForChild("Root Hip")
local orig = j.C0
function placeAtMouse()
-- make sure the mouse is pointing at something
if mouse.Target then
-- where we cast our ray from (shifted slightly up so the ray will hit the surface we're hovering)
local point = moveModel.Torso.Position;
local ray = Ray.new(
moveModel.Torso.Position,
Vector3.new(0, -10, 0)
)
local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel)
if hit ~= nil then
local origin = point + Vector3.new(0, 0.1, 0)
-- cast our ray and get our normal, which is a unit vector
local ray = Ray.new(origin, Vector3.new(0, -1, 0))
-- get the perpendicular vector and the angle between the two
local cross = Vector3.new(0, 1, 0):Cross(normal)
local angle = math.asin(cross.magnitude) -- division by 1 is redundant
print(angle)
local savedCFrame = moveModel.Torso.Orientation;
j.C0 = orig*CFrame.fromAxisAngle(cross.magnitude == 0 and Vector3.new(1) or cross, angle)
brick.CFrame = part.CFrame
local newCFrame;
end
end
end
This script down here!!!
local player = game:GetService("Players").LocalPlayer;
local character = player.CharacterAdded:wait();
local torso = character:WaitForChild("HumanoidRootPart");
function drawray(ray, parent)
local part = Instance.new("Part", parent or game.Workspace.CurrentCamera);
part.FormFactor = Enum.FormFactor.Custom;
part.Material = Enum.Material.Neon;
part.Size = Vector3.new(.2, ray.Direction.magnitude, .2);
part.CFrame = CFrame.new(ray.Origin + ray.Direction/2, ray.Origin + ray.Direction) * CFrame.Angles(math.pi/2,0,0);
part.Anchored = true;
part.CanCollide = false;
part.BrickColor = BrickColor.new("Bright red");
--Instance.new("SpecialMesh", part);
return part;
end;
local part = Instance.new("Part");
part.Anchored = true;
part.CanCollide = false;
part.FormFactor = Enum.FormFactor.Custom;
part.Material = Enum.Material.Neon;
part.Size = Vector3.new(2, 1, 2);
part.TopSurface = Enum.SurfaceType.Smooth;
part.BottomSurface = Enum.SurfaceType.Smooth;
part.BrickColor = BrickColor.Green();
function init()
local ray = Ray.new(torso.Position, Vector3.new(0, -50, 0));
local hit, pos, normal = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(ray, {character});
local cross = normal:Cross(Vector3.new(0, 1, 0));
local angle = math.asin(cross.magnitude);
local lateral = torso.CFrame - torso.CFrame.p;
local new = part
new.Name = "Part1"
new.Parent = character
new.CFrame = CFrame.new(pos) * CFrame.fromAxisAngle(cross == Vector3.new() and Vector3.new(1) or cross, -angle) * lateral;
end;
print("Hello")
game:GetService("RunService").RenderStepped:connect(function()
init();
end);
