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

Tool that is meant to move your arm not working, how should I fix it?

Asked by 3 years ago

I've tried making a tool that moves your arm in the direction of your mouse, I've done a local script, server script, and remove function inside the tool

Server script code:

local Tool = script.Parent
local Character = Tool.Parent

Tool.Equipped:Connect(function()
    Character = Tool.Parent
    Player = game:FindService("Players"):GetPlayerFromCharacter(Character)
    Root = Character:WaitForChild("HumanoidRootPart")
    RightArm = Character:WaitForChild("Right Arm")
end)

Tool.Activated:Connect(function()
    CFrame.new(RightArm.Position, Tool.DirectionInvoker:InvokeClient(Player).Position)
end)

Local script code:

local Tool = script.Parent
local Character = Tool.Parent
local Player = game:FindService("Players"):GetPlayerFromCharacter(Character)

local DirectionInvoker = Tool:WaitForChild("DirectionInvoker", 10)
DirectionInvoker.OnClientInvoke = function()
    local NewPlayer = game.Players.LocalPlayer
    if NewPlayer and NewPlayer:IsA("Player") then
        local Mouse = NewPlayer:GetMouse()
        if Mouse then
            local Table = {
                Hit = Mouse.Hit,
                Position = Mouse.Hit.p,
                Target = Mouse.Target
            }
            return Table
        end
    end
    local Table = {
        Hit = nil,
        Position = Vector3.new(0,0,0),
        Target = nil
    }
end

The Remote Function is called DirectionInvoker

1 answer

Log in to vote
0
Answered by
Necro_las 412 Moderation Voter
3 years ago

When you activated the Tool, you only have created a CFrame with the data gotten from client, but you didn't do anything with that CFrame. Moving the arm in the direction of the mouse is actually way more complicated sinse you would have to work with editing the char's Motor6D's CFrames.

This video gives some Idea of how it would work: https://www.youtube.com/watch?v=HjfjWySxRRA

Ad

Answer this question