Hi! I am a new scripter/developer in Roblox and idk a lot of things. I started working on a game and trying to make the player arm move where the mouse clicked in the world. I did that, so if you can help me ill be very happy
local script in the player :
local RS = game:GetService("ReplicatedStorage")
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function()
local position = mouse.Hit.p
print(position)
RS.Click:FireServer(position)
end)
serverside script :
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClickEvent = ReplicatedStorage:WaitForChild("Click")
local function ExtendRightArm(player, position, extensionDistance)
local character = player.Character
if character then
local rightUpperArm = character:FindFirstChild("RightUpperArm")
local rightLowerArm = character:FindFirstChild("RightLowerArm")
local rightHand = character:FindFirstChild("RightHand")
if rightUpperArm and rightLowerArm and rightHand then
local originalCFrameUpper = rightUpperArm.CFrame
local originalCFrameLower = rightLowerArm.CFrame
local originalCFrameHand = rightHand.CFrame
local endPositionUpper = rightUpperArm.Position + rightUpperArm.CFrame.LookVector * extensionDistance
local endPositionLower = rightLowerArm.Position + rightLowerArm.CFrame.LookVector * extensionDistance
local endPositionHand = rightHand.Position + rightHand.CFrame.LookVector * extensionDistance
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local tweenUpper = TweenService:Create(rightUpperArm, tweenInfo, {CFrame = CFrame.new(endPositionUpper)})
local tweenLower = TweenService:Create(rightLowerArm, tweenInfo, {CFrame = CFrame.new(endPositionLower)})
local tweenHand = TweenService:Create(rightHand, tweenInfo, {CFrame = CFrame.new(endPositionHand)})
tweenUpper:Play()
tweenLower:Play()
tweenHand:Play()
wait(2)
tweenUpper:Cancel()
tweenLower:Cancel()
tweenHand:Cancel()
rightUpperArm.CFrame = originalCFrameUpper
rightLowerArm.CFrame = originalCFrameLower
rightHand.CFrame = originalCFrameHand
else
warn("Right arm parts not found.")
end
else
warn("Character not found.")
end
end
ClickEvent.OnServerEvent:Connect(function(player, position)
local extensionDistance = 5
ExtendRightArm(player, position, extensionDistance)
end)
i used a little chat gpt to make the server side script, but the principal idea is from me.
sorry if its bad, im new and need lot of help todo my scripts