You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want it so Motor6D transform works when 2 players play the game.
- What is the issue? Include screenshots / videos if possible!
– When 2 players play the game
– Actual server
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yeah but nothing matches my search.
///////////////////////////////////////////////////////////
Server
local LeftShoulder = script.Parent.Integers.LeftShoulder
local RightShoulder = script.Parent.Integers.RightShoulder
local DirectionL = LeftShoulder.Direction.Value
local DirectionR = RightShoulder.Direction.Value
local ReplicatedTweening = require(game.ReplicatedStorage.ReplicatedTweening)
wait();
script.Parent.E:GetPropertyChangedSignal("Value"):Connect(function()
if script.Parent.E.Value == true then
script.Parent.Parent:FindFirstChild("Torso"):FindFirstChild("Left Shoulder").Transform = CFrame.new(Vector3.new(0, 0, 0)) * CFrame.Angles(0, 0, 0)
Or = game:GetService('RunService').Stepped:Connect(function()
local rootCFrame = script.Parent.Parent:FindFirstChild("HumanoidRootPart").CFrame;
local rotationOffset = (rootCFrame - rootCFrame.Position):inverse();
script.Parent.Parent:FindFirstChild("Torso"):FindFirstChild("Right Shoulder").Transform = rotationOffset * CFrame.new(Vector3.new(0, 0, 0)) * CFrame.Angles(math.pi / 2, 0, 0)
end)
if Ol ~= nil then
Ol:Disconnect()
end
end
end)
script.Parent.Q:GetPropertyChangedSignal("Value"):Connect(function()
if script.Parent.Q.Value == true then
Ol = game:GetService('RunService').Stepped:Connect(function()
local rootCFrame = script.Parent.Parent:FindFirstChild("HumanoidRootPart").CFrame;
local rotationOffset = (rootCFrame - rootCFrame.Position):inverse();
script.Parent.Parent:FindFirstChild("Torso"):FindFirstChild("Left Shoulder").Transform = rotationOffset * CFrame.new(Vector3.new(0, 0, 0)) * CFrame.Angles(math.pi / 2, 0, 0)
end)
if Or ~= nil then
Or:Disconnect()
end
end
end)
script.Parent.EInt.OnServerEvent:Connect(function(Player, State)
script.Parent.E.Value = State
end)
script.Parent.QInt.OnServerEvent:Connect(function(Player, State)
script.Parent.Q.Value = State
end)
Client
--- Services ---
local Players = game:GetService("Players");
local RunService = game:GetService("RunService");
wait();
--- Declarations ---
local Player = Players.LocalPlayer;
local Character = game.Workspace:WaitForChild(Player.Name);
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
local Mouse = Player:GetMouse();
--- Character ---
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart");
local RightShoulder = Character:WaitForChild("Torso"):WaitForChild("Right Shoulder");
local LeftShoulder = Character:WaitForChild("Torso"):WaitForChild("Left Shoulder");
local RC = nil
local LC = nil
local L = false
local R = false
local OLDL
local OLDR
local PLACEL
local PLACER
local OrientationL
local OrientationR
--- Execution ---
game:GetService("UserInputService").InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E and R == false then
R = true
L = false
--[[pcall(function()
PLACER:Disconnect()
end)]]
game:GetService("TweenService"):Create(LeftShoulder, TweenInfo.new(0.2), {Transform = CFrame.new(Vector3.new(0, 0, 0)) * CFrame.Angles(0, 0, 0)}):Play()
script.QInt:FireServer(false)
script.EInt:FireServer(true)
RC = RunService.Stepped:Connect(function()
local hit = Mouse.Hit;
-- add the lookVector * 5000 to the hit.p to make the point more "dramatic" (remove it and you'll see why I did this)
local direction = hit.p + (hit.lookVector * 5000);
-- get the rotation offset (so the arm points correctly depending on your rotation)
local rootCFrame = HumanoidRootPart.CFrame;
local rotationOffset = (rootCFrame - rootCFrame.p):inverse();
-- since CFrames are relative, put the rotationOffset first, and then multiple by the point CFrame, and then multiple by the CFrame.Angles so the arm points in the right directio
OrientationR = rotationOffset * CFrame.new(Vector3.new(0, 0, 0), direction) * CFrame.Angles(math.pi / 2, 0, 0);
game:GetService("TweenService"):Create(RightShoulder, TweenInfo.new(0.2), {Transform = OrientationR}):Play()
wait(1)
game.ReplicatedStorage.Set:FireServer(script.Integers.RightShoulder.Direction, direction)
end)
pcall(function()
LC:Disconnect()
end)
elseif Input.KeyCode == Enum.KeyCode.Q and L == false then
R = false
L = true
--[[pcall(function()
PLACEL:Disconnect()
end)]]
script.QInt:FireServer(true)
script.EInt:FireServer(false)
LC = RunService.Stepped:Connect(function()
local hit = Mouse.Hit;
-- add the lookVector * 5000 to the hit.p to make the point more "dramatic" (remove it and you'll see why I did this)
local direction = hit.p + (hit.lookVector * 5000);
-- get the rotation offset (so the arm points correctly depending on your rotation)
local rootCFrame = HumanoidRootPart.CFrame;
local rotationOffset = (rootCFrame - rootCFrame.p):inverse();
-- since CFrames are relative, put the rotationOffset first, and then multiple by the point CFrame, and then multiple by the CFrame.Angles so the arm points in the right direction
OrientationL = rotationOffset * CFrame.new(Vector3.new(0, 0, 0), direction) * CFrame.Angles(math.pi / 2, 0, 0);
game:GetService("TweenService"):Create(LeftShoulder, TweenInfo.new(0.2), {Transform = OrientationL}):Play()
wait(1)
game.ReplicatedStorage.Set:FireServer(script.Integers.LeftShoulder.Direction, direction)
end)
pcall(function()
RC:Disconnect()
end)
end
end)