For some reason the CurrentAngle is set on the server, but in the game it doesn’t change. We tried making a cycle that sets the CurrentAngle to the one we set beforehand on the server, but it doesn’t work.
We’re resulting with this:
on the server there is a cycle that every .5 seconds sets the desired currentAngle
So, here’s how it looks like in the game.
Motor6D CurrentAngle(Assault Rifle):
The main problem is that the weapon is located in the hands of the character incorrectly
Here serverside code:
local character = p.Character
if character:FindFirstChild('RightHand') then
if character:FindFirstChild('RightHand'):FindFirstChild('Main') then
character:FindFirstChild('RightHand'):FindFirstChild('Main'):Destroy()
end
end
gunRig.Name = "Gun"
gunRig.Parent = p.Character
equips[p.UserId] = {rig = gunRig;}-- motor = motorForRig}
gunRig.PrimaryPart.Anchored = false;
local gunMotor6D = gun.Motor6D:Clone();
gunMotor6D.Part0 = p.Character:FindFirstChild("RightHand");
gunMotor6D.Part1 = character:FindFirstChild('Gun').PrimaryPart
repeat gunMotor6D.Part1 = character:FindFirstChild('Gun').PrimaryPart wait() until gunMotor6D.Part1 == character:FindFirstChild('Gun').PrimaryPart
gunMotor6D.CurrentAngle = 0;
gunMotor6D.Name = "Main";
gunMotor6D.Parent = p.Character:FindFirstChild("RightHand");
And serverside While .5 Loop:
spawn(function()
while wait(.5) do
for i,v in next, game.Players:GetPlayers()do
local character = v.Character or v.CharacterAdded:wait()
if character then
local gun = character:FindFirstChild('Gun')
local gunName = nil
if gun then
gunName = gun:WaitForChild'GunName'.Value
end
if gunName ~= nil then
local hand = character:FindFirstChild('RightHand')
if hand then
local motor6 = hand:FindFirstChild('Main')
if motor6 then
motor6.CurrentAngle = 0
wait()
motor6.CurrentAngle = weaponStats[gunName].Motor6DAngle
end
end
end
end
end
end
end)
Your help will be much appreciated!