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. When the server scripts remote function is completed, it stops when it returns back to the local script, it doesn’t progress after the initial local script’s invoke call.
The remote function I am working with is “charChange”
--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)
This is what my workspace looks like
