Button that turns monster mode on and off

Hey there!

So i’m making a button for a chosen player that allows them to switch monster mode on and off. All monster mode really is, is shifting the player’s character from their original look to the monster skin (Cloning the monster skin from ServerStorage and making it their character). Iv’e already got that system done. However, i need for the player to be able to go back to human mode (their original look), and i’m not sure how to get their original character back once their in the monster skin.

Here’s the scripts:

SCRIPT IN BUTTON

local module = require(game.ServerScriptService.GameLogic.MonsterButtons)

local player = script.Parent.Parent.Parent.Parent

local MonsterOn = false

local OriginalCharacter = player.Character


script.Parent.MouseButton1Click:Connect(function()
	if MonsterOn == false then
		MonsterOn = true
		script.Parent.Image = script.Parent.On.Value
		module.Monster(player)
	elseif MonsterOn == true then
		MonsterOn = false
		script.Parent.Image = script.Parent.Off.Value
		module.Player(player, OriginalCharacter)
	end
end)

MODULE SCRIPT IN SERVERSCRIPTSERVICE UNDER 'GAMELOGIC’

local module = {}

function module.Monster(player)
	local character = player.Character
	local Position = player.Character.HumanoidRootPart.CFrame
	local Monster = game.ServerStorage.Monster:Clone()
	
	
	Monster.Name = player.Name
	
	player.Character = Monster
	
	Monster.Parent = workspace
	
	Monster.HumanoidRootPart.CFrame = Position
end

function module.Player(player, OriginalCharacter)

--All the stuff

end

return module

Any help on how to save the player’s original character’s model would really be appreciated :+1:

1 Like

There may be a better way to do this, but you can use LoadCharacter() to simply refresh the player, and then bring them back to their position.

function module.Player(player, OriginalCharacter)
	local cframe = player.Character.HumanoidRootPart.CFrame
	player:LoadCharacter()
	player.Character.HumanoidRootPart.CFrame = cframe
end
3 Likes

Thank you! Also can the CFrame of the player’s camera be the same as it was before the transformation? The camera seems to take a 45 degree turn everytime i transform.

Thanks for the help! :+1:

When you use LoadCharacter() the camera will reset as well, which is why I said there might be a better method. You could always use a remote function to return the client’s camera CFrame, and then after loading the character send a remote to return the cframe. Something like this (untested)

-- Module script
function module.Player(player, OriginalCharacter)
	local cframe = player.Character.HumanoidRootPart.CFrame
	local cameraCF = RemoteFunction:InvokeClient(player)
	player:LoadCharacter()
	player.Character.HumanoidRootPart.CFrame = cframe
	RemoteEvent:FireClient(player, cameraCF)
end



-- LocalScript in StarterCharacterScripts
local Camera = workspace.CurrentCamera

RemoteFunction.OnClientInvoke = function()
	return Camera.CFrame
end

RemoteEvent.onClientEvent:Connect(function(cframe)
	Camera.CFrame = cframe
end)
1 Like

Thanks! I also implemented that function thanks to you :+1:

1 Like

Hello “LoadCharacter can only be called by the backend server” error can u help me