GUI button morphs a player into a model (How to do it?)

Hi! I’m new to scripting and need a bit of help.
I made a GUI that has buttons, and when a player presses a button, they are supposed morph into the model that corresponds with that button. But I have no idea how to do that…
Example:
the “Hi” button will morph you into the “Hi” morph
the “Bye” button will morph you into the “Bye” morph… etc
So if anyone can help me out with this, it would be very appreciated!
Thanks!

These are the morphs that I’m talking about. They are morphs that are made to fit above a character. But I’m not sure what would be the best way to do this.

6 Likes

Maybe look on a tutorial on how to script the buttons to turn into the morphs you want.

1 Like

I have but, I haven’t seen anything :confused:

https://www.youtube.com/watch?v=zXbNSid4RME Maybe this?

If that doesn’t work for you then, maybe try making buttons that when you step on you morph. Sorry if I’m not such a big help I don’t know much about scripting morph gui or buttons.

1 Like

Use a LocalScript for the TextButton

Use a Script for the RemoteEvent

The LocalScript would be something like

-- Place this code in a LocalScript in a TextButton
local textButton = script.Parent

local MorphEvent = game.ReplicatedStorage:WaitForChild("MorphEvent")
 
-- Here, we define a function
local function onActivated()	
	-- This will send the server a message
	MorphEvent:FireServer('Hi')
end
 
-- Connect the "Activated" event to our function
textButton.Activated:Connect(onActivated)

And the server sided Script would be something like

local ReplicatedStorage = game.ReplicatedStorage
local MorphEvent = Instance.new("RemoteEvent", ReplicatedStorage)
MorphEvent.Name = "MorphEvent"
 
function onMorphEventFired(callingPlayer, requestedMorphName)
	print(player.Name, "wants to morph into a ",requestedMorphName)
	if requestedMorphName == "Hi" then -- Always good to have some sort of check
		-- Create a clone of the body
		local newBody = game.ServerStorage:FindFirstChild('Hi'):Clone()
		-- Move the new body to where the player is standing
		newBody:MoveTo(callingPlayer.Character.HumanoidRootPart.Position)
		-- Set the model as the character's body
		callingPlayer.Character = newBody
	end
end
 
MorphEvent.OnServerEvent:Connect(onMorphEventFired)

This code is untested but it should give you a basic idea of how to do this.

10 Likes

Lol, it’s all good. It happens all the time

Another question, since I’m super new to scripting, the Script (not local) would go where?
And also, where would I put the model in the script? Like how does it know which one it’s using?
Do you have a discord where I can speak about this more?