Player model put into remoteFunction returns boolean instead of model

  1. What do you want to achieve?
    I’m trying to insert a motor inside the torso for a tool animation. The tool has no handle so I use part parents to detect when it is equipped or not.

  2. What is the issue?
    When I try to use the player model as an argument for a remote function, the function returns a boolean for it instead of the model

  3. What solutions have you tried so far?
    I’ve looked for solutions, but so far I have found none.

Server Script

motorConnect.OnServerInvoke = function(motor,bodyAttach,connect,playerModel)
	
	print(playerModel) -- this returned a boolean in the console instead of the model
	
	if motor.Parent.Name ~= "Torso" then
		
		motor.Parent = playerModel:WaitForChild("Torso")
		motor.Part0 = playerModel:WaitForChild("Torso")
		
	end
	
	if connect then
		
		motor.Part1 = bodyAttach
		
	else
		
		motor.Part1 = nil
		
	end
	
end

Local Script

local players = game:GetService("Players")
local char = players.LocalPlayer.Character


tool:GetPropertyChangedSignal("Parent"):Connect(function()
	
	if tool.Parent.Name == char.Name then
		
		motorConnect:InvokeServer(motor,bodyAttach,true,char)
		animFunc:InvokeServer("Hold",true,char)
		
	end
	
end)

The first argument that is passed to the function in OnServerInvoke is always the player that’s invoking the remote, and then the rest of the arguments that were passed to InvokeServer, so instead the function signature should be like this

function(player, motor, bodyAttach, connect, playerModel)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.