I want to create a morph gui that works for the most part, except for 2 things.
when player morphs the camera wont lock onto morph
morph not displaying any animations
video example:
Local scipt code (in textbutton):
local textButton = script.Parent
local MorphEvent = game.ReplicatedStorage:WaitForChild("morphing")
local function onActivated()
MorphEvent:FireServer("Lemon")
end
textButton.Activated:Connect(onActivated)
Serverscript (in ServerScriptService):
local ReplicatedStorage = game.ReplicatedStorage
function onMorphEventFired(plr, morph)
local newBody = game:GetService("ServerStorage").morphs:FindFirstChild(morph):Clone()
newBody.Parent = workspace
newBody.Name = plr.Name
repeat wait() until newBody
newBody:MoveTo(plr.Character.HumanoidRootPart.Position)
plr.Character = newBody
end
ReplicatedStorage.morphing.OnServerEvent:Connect(onMorphEventFired)
when player morphs the camera wont lock onto morph
Add this to LocalScript
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Follow
Camera.CameraSubject = Character.PrimaryPart
morph not displaying any animations
I made a special note even, in ServerScript do this
NewChar.Name = player.Name
player.Character = NewChar --if this is after workspace parent, no animations
--animation seemsto work if parenting last,
NewChar.Parent = workspace
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local RemoteEvent = ReplicatedStorage:WaitForChild("morphing")
local Button = script.Parent
--//Functions
Button.MouseButton1Click:Connect(function()
RemoteEvent:FireServer("Lemon")
end)
ServerScript:
--//Services
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local RemoteEvent = ReplicatedStorage:WaitForChild("morphing")
--//Functions
RemoteEvent.OnServerEvent:Connect(function(Player, MorphName)
local Morph = ServerStorage:FindFirstChild(MorphName)
if Morph and Player.Character then
local NewBody = Morph:Clone()
NewBody.Name = Player.Name
NewBody:PivotTo(Player.Character:GetPivot())
Player.Character = NewBody
NewBody.Parent = workspace
end
end)
both the camera and animation has been solved, in the game a script will insert an animation script into the player, however the animations only play client side if you are a morph, it works fine otherwise. is there something im missing?
heres the animation insert scipt
game.Players.PlayerAdded:Connect(function(plr)
print(plr.Name.." Joined The Game")
plr.CharacterAdded:Connect(function(char)
print(plr.Name.." Character Is Loaded")
wait(1)
if not plr.Character:FindFirstChild("Health") then
script.Health:clone().Parent = plr.Character
end
if char:FindFirstChild("Animate") then
print("found animate script in "..plr.Name..", Deleting..." )
if char.Humanoid.RigType == Enum.HumanoidRigType.R6 then
char:FindFirstChild("Animate"):Remove()
print(plr.Name.." Is R6")
local newaniamte = script.R6.Animate:Clone()
print("Adding New Animate script into "..plr.Name.."...")
newaniamte.Parent = char
elseif char.Humanoid.RigType == Enum.HumanoidRigType.R15 then
print(plr.Name.." Is R15")
end
else
print("no animate script found in "..plr.Name )
script.R6.Animate:clone().Parent = char
if char.Humanoid.RigType == Enum.HumanoidRigType.R6 then
char:FindFirstChild("Animate"):Remove()
print(plr.Name.." Is R6")
local newaniamte = script.R6.Animate:Clone()
print("Adding New Animate script into "..plr.Name.."...")
newaniamte.Parent = char
elseif char.Humanoid.RigType == Enum.HumanoidRigType.R15 then
print(plr.Name.." Is R15")
end
end
end)
end)
edit: it seem that no animations seem to play at all im not sure whats going on