RenderStep Issue

Hello Devs, I am working on a catching system and I wanted to use RenderStep inside of a serverscript. I want to make it so other players could also see your arms and others’ arms move. There is a slight problem with that. RenderStep can only be used in local scripts and I am looking for help to see if there’s a way around this. Please help.



-- Services --
local Character = script.Parent
local Player = game:GetService('Players'):GetPlayerFromCharacter(Character)
local Replicated = game:GetService('ReplicatedStorage')
local Mouse = Player:GetMouse()
local CRem = Replicated.Remotes:WaitForChild('CRemote')

-- Values --
local CatchDebounce = false
local Football = nil

-- Functions --
local function TrackBall(Object)
	for I,V in pairs(workspace:GetChildren()) do
		if (V.Name == 'Football' and V:IsA('Part')) or (V.Name == 'Football' and V.Name == ('Handle')) then
			Football = V

CRem.OnServerEvent:Connect(function(Player, Action, ...)
	local Char = Player.Character
	if not Character:FindFirstChild('Football') then
		local Instances = Character:WaitForChild( 'Instances' )
		local RAWeld = 'Weld' )
		local LAWeld = 'Weld' )
		RAWeld.Name = 'RAW'
		RAWeld.Part0 = Char.Torso
		RAWeld.Part1 = Character['Right Arm']
		RAWeld.Parent = Instances
		LAWeld.Name = 'LAW'
		LAWeld.Part0 = Char.Torso
		LAWeld.Part1 = Character['Right Arm']
		LAWeld.Parent = Instances
		if not CatchDebounce then CatchDebounce = true end
		local RunService = game:GetService('RunService')
		local STime = os.time()
		local Track
		Track = RunService.RenderStepped:Connect(function()
			local RCFrame = *, 1.1, 0), Mouse.Hit.Position) * CFrame.Angles(math.pi / 2, 0, 0)
			local LCFrame = *, 1.1, 0), Mouse.Hit.Position) * CFrame.Angles(math.pi / 2, 0, 0)
			RAWeld.C0 = Char.Torso.CFrame:toObjectSpace(RCFrame) *, -.7, .6)
			LAWeld.C0 = Char.Torso.CFrame:toObjectSpace(LCFrame) *, -.7, .6)
			if os.time() - STime >= 3 then
				if os.time() -  STime >= 0.5 then
					CatchDebounce = false


-- Instances --
local InputService = game:GetService('UserInputService')
local Player = game:GetService('Players').LocalPlayer
local Character = script.Parent.Parent
local Mouse = Player:GetMouse()

local CRem = game.ReplicatedStorage.Remotes:WaitForChild('CRemote')

-- Values --
local Football = game.ReplicatedStorage

-- Functions --
--local function TrackBall(Object)
--	for I,V in pairs(workspace:GetChildren()) do
--		if (V.Name == 'Football' and V:IsA('Part')) or (V.Name == 'Football' and V.Name == ('Handle')) then
--			Football = V
--		else
--			TrackBall(V)
--		end
--	end

-- Work Remote --
	if GPE then return end
	local Type = Input.UserInputType
	if Type == Enum.UserInputType.MouseButton1 then
		--if Football ~= nil then
		--	if Football:IsDescendantOf(game.Workspace) == true then

RenderStepped event only works in clients as it fires when client starts rendering process on every frame, which server does not do under normal circumstances.

You should use Stepped or Heartbeat event instead to run code before or after the physics simulation has been performed respectively.

1 Like

So. I should try changing renderstepped to stepped or HeartBeat correct?

Yeah, use the one that works better for your purposes.

Okay, Thank you for your suggestion Ill check it out

I’ve ran across another problem. The error is now were the Mouse.Hit.Position line in the server script is there anyway I can edit that?

This line right here
local RCFrame = *, 1.1, 0), Mouse.Hit.Position) * CFrame.Angles(math.pi / 2, 0, 0)

local RCFrame = CFrame.lookAt(Char.Torso.Position +, 1.1, 0), Mouse.Hit.Position) * CFrame.Angles(math.pi / 2, 0, 0)
1 Like

Its still giving me the same error sadly.

Oh, your issue is because the mouse object doesn’t exist as well.

you cant get the player mouse from the server so instead send the player mouse position to the server when fireing ur remote event



CRem.OnServerEvent:Connect(function(Player, Action, MousePosition)

local RCFrame = *, 1.1, 0), MousePosition) * CFrame.Angles(math.pi / 2, 0, 0)

Those changes I proposed are still necessary but in addition to that (as the previous poster suggested) you need to pass the mouse’s position from the client as the mouse object only exists on the client.

That did work but it’s not updating with the mouse’s position. If I click yeah it will go to the mouses position but if I move around the mouse the arms stay there

Then you need to fire the server each time the mouse moves.

	--fire server and pass mouse's position
1 Like

Also. How could I prevent the weld spam from happeneing?

Check if the weld already exists before creating it or destroy old welds before creating new ones.

I can do that by using a if statement right?

Yeah, it’d be like

if Char.Instances:FindFirstChild'LAW' == nil then
1 Like

@Forummer For some reason now my hands decide to stop while im still moving my mouse. Then welds get destroyed