I'm trying to make it so when you click a button your character does an animation and then his character is changed, when he does it again he goes back to his normal character.
Server:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HoodUp= ReplicatedStorage.HoodUp
local HoodDown= ReplicatedStorage.HoodDown
local hoodupchar = ReplicatedStorage.HoodUpChar
local hoodupcharclone = hoodupchar:Clone()
HoodUp.OnServerEvent:Connect(function(Player, Name)
local UserId = Players:GetUserIdFromNameAsync(Name)
local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(UserId)
Player.Character = hoodupcharclone
end)
HoodDown.OnServerEvent:Connect(function(Player, Name)
local UserId = Players:GetUserIdFromNameAsync(Name)
local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(UserId)
Player:LoadCharacterWithHumanoidDescription(HumanoidDescription)
end)
Client
local player = game.Players.LocalPlayer
local character = player.Character
repeat wait()
character = player.Character
until character
local hum = character:WaitForChild("Humanoid")
local emote = hum:LoadAnimation(script.Parent.Emote)
playing = false
character = false
script.Parent.MouseButton1Click:connect(function()
if playing == false then
if character == false then
emote:Play()
playing = true
wait(emote.Length - 0.1)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeCharacter = ReplicatedStorage.HoodUp
script.Parent.MouseButton1Click:Connect(function()
ChangeCharacter:FireServer(player)
character = true
end)
wait(0.1)
playing = false
end
end
if playing == false then
if character == true then
emote:Play()
playing = true
wait(emote.Length - 0.1)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeCharacter = ReplicatedStorage.HoodDown
script.Parent.MouseButton1Click:Connect(function()
ChangeCharacter:FireServer(player)
end)
wait(0.1)
playing = false
end
end
end)

3 comments
thanks i'm going to try to make it work
wait how would i make it so he can toggle on a character and toggle off a character?
I edited my post so you can see the client sided script