Making a script to change the player's character model to another model that the player clicked. The server script works properly, just not the local script.

--Server Script
local rp = game.ReplicatedStorage
local charChange = script.Parent:WaitForChild("charChange")

charChange.OnServerInvoke = function(plr,rig)
	local health = rp.Health:Clone()
	local crig = rig:Clone()
	crig:SetPrimaryPartCFrame(plr.Character.PrimaryPart.CFrame)
	crig.Parent = workspace
	health.Parent = crig
	health.Disabled = false
	plr.Character = crig
	print("On server "..crig.Name)
	return crig
end

--Local Script 

local lp = game:GetService("Players").LocalPlayer
local mouse = lp:GetMouse()
local rp = game.ReplicatedStorage
local charChange = script.Parent:WaitForChild("charChange")
mouse.Button1Down:connect(function()
	local touch = mouse.Target
	if touch ~= nil then
		if touch.Parent:FindFirstChild("Humanoid") then
			local crig = charChange:InvokeServer(touch.Parent) -- Remote function gets called here
--The code stops here. Anything after this doesn't happen. 
			print("On Client "..crig.Name)
			local animate = rp.Animate:Clone()
			animate.Parent = crig
			animate.Disabled = false		
			local camera = game.Workspace.CurrentCamera
			camera.CameraType = "Follow"
			camera.CameraSubject = crig:FindFirstChild("Head")
		end
	end
end)

2 comments

0

That doesn't answer my question. I know the function call yeilds, but here the script just stops.

0

In your script and localscript, you put 'script.Parent:WaitForChild("charChange")'. Try 'rp:WaitForChild("charChange")'.