Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.