My game relies heavily on character morphs. When a player selects a morph, a GUI shows up that lets them change the morph's expression/pose/whatever. I refer to them as Animations. Once I started using FilteringEnabled, the character animations are only seen by the client. I was wondering why this was happening and how I can change it. Here's an example of the scripts I've been using (both are in local scripts):
playerman = script.Parent.Parent.Parent.Parent.Parent.Character function change() playerman.Chest.Smile.Transparency=0 playerman.Chest.Frown.Transparency=1 wait() script.Parent.t.Disabled = false script.Disabled = true end script.Parent.MouseButton1Click:connect(change)
If the button is pressed again, it will put the morph back to its neutral state.
playerman = script.Parent.Parent.Parent.Parent.Parent.Character function change() playerman.Chest.Smile.Transparency=1 playerman.Chest.Frown.Transparency=0 wait() script.Parent.e.Disabled = false script.Disabled = true end script.Parent.MouseButton1Click:connect(change)
I've been trying to fix this for so long, but I can't come up with a solution.
You today are going to learn to use RemoteEvents~
Okay, so for starters, it's only on the client side because it's a LOCAL script, meaning it'll only happen locally. To make it Server-side you'll have to make a Serverscript that catches the event. It's a little more code but worth it in the end. :P
-- Note: Put this script inside the ScreenGui, not the Buttons themselves. -- ClientSideScript -- || Services || local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") -- || Variables || local AnimationRemote = ReplicatedStorage:WaitForChild("AnimationRemote") local Player = Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local SmileButton -- = ButtonPathHere local FrownButton -- = ButtonPathHere -- || EventTriggerer || SmileButton.MouseButton1Click:connect(function() AnimationRemote:FireServer("Smile") end) FrownButton.MouseButton1Click:connect(function() AnimationRemote:FireServer("Frown") end)
So, we've just set up to make it so the Buttons trigger something called a RemoteEvent, now we just have to create that RemoteEvent so it doesn't error.
-- Note: Put this script inside of ServerScriptService -- ServerSideScript -- || Services || local ReplicatedStorage = game:GetService("ReplicatedStorage") -- || Variables || local AnimationRemote = Instance.new("RemoteEvent", ReplicatedStorage) AnimationRemote.Name = "AnimationRemote" -- || EventHandler || AnimationRemote.OnServerEvent:connect(function(Ply, Animation) if Animation == "Smile" then Ply.Character.Chest:FindFirstChild("Smile").Transparency = 0 Ply.Character.Chest:FindFirstChild("Frown").Transparency = 1 elseif Animation == "Frown" then Ply.Character.Chest.FindFirstChild("Smile").Transparency = 1 Ply.Character.Chest:FindFirstChild("Frown").Transparency = 0 end end)
Be sure to let me know if I missed something
So far, I've made the Client fire the event to the server, which makes the Player's Animation changed based on the button pressed!
If this doesn't work, let me know in a comment and I'll edit the code.
Best of luck!