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

I'm making a gun with animations and I'm having mutliple problems, help?

Asked by
ZIRFAL3 17
3 years ago
Edited 3 years ago

I'm making a gun, and decided to add animations and make the player's arms follow the mouse. I have a problem and a question.

Firstly, I'm having a weird problem, I have the gun, but when I duplicate it, the second one's "follow camera" system doesn't work.. Here's the code

local plr = game.Players.LocalPlayer

repeat wait() until game.Players.LocalPlayer.Character
local char1 = plr.Character
local Anim = char1.Humanoid:LoadAnimation(script.Parent.Idle)

local RightArm = char1.Torso["Right Shoulder"].C0
local LeftArm = char1.Torso["Left Shoulder"].C0
local Neck = char1.Torso["Neck"].C0

local ChangeVariable = false

repeat wait() until game.Players.LocalPlayer.Character

local char = plr.Character
local m = plr:GetMouse()

game["Run Service"].RenderStepped:Connect(function()

    if script.Parent.BoolEquipped.Value == true then

        local c = game.Workspace.CurrentCamera
        char.Torso["Right Shoulder"].C0 = CFrame.new(1,0.5,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y),1.55,0)
        char.Torso["Left Shoulder"].C0 = CFrame.new(-1,0.5,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y),-1.55,0)
        char.Torso["Neck"].C0 = CFrame.new(0,1,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55,3.15,0)

    else

        local c = game.Workspace.CurrentCamera
        char.Torso["Right Shoulder"].C0 = RightArm
        char.Torso["Left Shoulder"].C0 = LeftArm
        char.Torso["Neck"].C0 = Neck

    end

end)

script.Parent.Unequipped:Connect(function()

    char.Torso["Right Shoulder"].C0 = CFrame.new(0,0,0)
    char.Torso["Left Shoulder"].C0 = CFrame.new(0,0,0)
    char.Torso["Neck"].C0 = CFrame.new(0,0,0)

end)

script.Parent.Equipped:Connect(function()

    Anim:Play()

end)

script.Parent.Unequipped:Connect(function()

    Anim:Stop()

end)

I also have a question, does anyone know how can I make it so that the character's arms follow the mouse, but in a server script?

0
Use a remote event to fire from server to client, cuz there is no way to make arms move with a server script, as you cannot get the local player sne_123456 439 — 3y
0
and i dont get wht u mean by: Firstly, I'm having a weird problem, I have the gun, but when I duplicate it, the second one's "follow camera" system doesn't work.. Here's the code sne_123456 439 — 3y
0
Lets say I have the gun, and I duplicate it (two have the same weapon two times), the new weapon (the clone) doesn't move the character's arms even though it's the exact same tool as the original one. ZIRFAL3 17 — 3y
0
oh i get it. So can you tell me where the script is? sne_123456 439 — 3y
View all comments (3 more)
0
the script is inside the tool ZIRFAL3 17 — 3y
0
ping Xapelize 2658 — 2y
0
check reply on my answer Xapelize 2658 — 2y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago

It's not recommended to use a remote event to fire the mouse position to server, but if you want to do so, fire the mouse position every 0.5 seconds so it won't take your performance by a lot. The only downsides is it will take more performance than using local script to control head movement instead of remoting it to the server, and the head movement won't be smooth

0
But are there any other ways of firing the mouse position to the server? ZIRFAL3 17 — 2y
0
no there is not Xapelize 2658 — 2y
Ad

Answer this question