Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Fix Emotes

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

--// Services \\--

local SvSt = game:GetService('ServerStorage')


local TS = game:GetService('TweenService')
local RS = game:GetService('ReplicatedStorage')

--// Communication \\--

local ReplicateSet = RS.Remotes.Replicate.Set


local EmotesComms = RS.Remotes.Emotes
local EmotesGet = EmotesComms.Get
local EmotesSet = EmotesComms.Set

--// Modules \\--

local RpModules = RS.Modules


local WeldSystem = require(RpModules.WeldSystem)

local SvModules = SvSt.Modules


local AnimationService = require(SvModules.AnimationService)
local SoundsModule = require(SvModules.SoundsModule)

-- StunHandler module to be required here


local StunHandler = require(SvModules.StunHandler)

--// Local Functions \\--

local function TriggerHumanoid(Character: Model, Params: { any })


local Humanoid: Humanoid = Character.Humanoid

Character:SetAttribute('DefaultRunSpeed', Params.RS)
Character:SetAttribute('DefaultWalkSpeed', Params.WS)
Character:SetAttribute('DefaultJumpPower', Params.JP)

Humanoid.WalkSpeed = Params.WS
Humanoid.JumpPower = Params.JP
Humanoid.AutoRotate = Params.AR
end

local function CheckIfStunned(Character: Model)


-- Check if the character is stunned before performing an emote
local IsStunned = StunHandler:IsStunned(Character)
return IsStunned
end

return {
Mad = function(Player: Player, Anim: Animation)
local Character = Player.Character

-- Check if character is stunned before proceeding


if CheckIfStunned(Character) then return end

local Humanoid: Humanoid = Character.Humanoid


local HumRP: BasePart = Character.HumanoidRootPart

local Track: AnimationTrack =


AnimationService:getAnimationTrack(Character, Anim)
local Stopped = true
local assets = {}
Track.Stopped:Once(function()
for _, v in assets do
if v and v.Parent then
v:Destroy()
end
end

if Stopped == true then return end

TriggerHumanoid(Character, { RS = 25; WS = 16; JP = 50; AR =


true; })
end)
AnimationService:playAnimation(Character, Anim)
task.delay(Track.Length - .1, function()
Stopped = false
end)

table.insert(assets, SoundsModule:PlaySound(script.Mad.Hits, HumRP, 1,


1))
table.insert(assets, SoundsModule:PlaySound(script.Mad.Roar, HumRP, 1,
-(script.Mad.Roar.TimeLength - 2), { DelayTime = 1.5; TweenInfo = TweenInfo.new(.5,
Enum.EasingStyle.Linear); }))

wait()

TriggerHumanoid(Character, { RS = 0; WS = 0; JP = 0; AR = true; })
end,

-- Add similar check for all other emote functions


['Dab Me Up'] = function(Player: Player, Anim: Animation)
local Character = Player.Character

-- Check if character is stunned before proceeding


if CheckIfStunned(Character) then return end

local Humanoid: Humanoid = Character.Humanoid


local HumRP: BasePart = Character.HumanoidRootPart

local Track: AnimationTrack =


AnimationService:getAnimationTrack(Character, Anim)
local Weld
local assets = {}

ReplicateSet:FireAllClients('RemoveEmoteSync', { MainChar =
Character; })

local syncC: RBXScriptConnection


syncC = EmotesSet.OnServerEvent:Connect(function(_, Target: Model,
EnemyCharacter: Model)
if Target == Character then
syncC:Disconnect()
ReplicateSet:FireAllClients('RemoveEmoteSync', { MainChar =
Character; })

local EnemyHumRP: BasePart =


EnemyCharacter.HumanoidRootPart

TriggerHumanoid(EnemyCharacter, { RS = 0; WS = 0; JP = 0;
AR = false; })
Humanoid.AutoRotate = false

Weld = WeldSystem.new(HumRP, EnemyHumRP, CFrame.new(0, 0, -


3.5) * CFrame.Angles(0, math.rad(180), 0), 2.817)
Weld:Start()

AnimationService:getAnimationTrack(EnemyCharacter,
Anim).Stopped:Once(function()
if Weld then
Weld:Stop()
Weld = nil
end

TriggerHumanoid(EnemyCharacter, { RS = 25; WS = 16;


JP = 50; AR = true; })
end)

AnimationService:adjustSpeed(Character, Anim, 1)
AnimationService:playAnimation(EnemyCharacter, Anim)

table.insert(assets, SoundsModule:PlaySound(script["Dab Me
Up"].Handshake, Character['Left Arm'], 1, 1))
end
end)

Track.Stopped:Once(function()
if Weld then
Weld:Stop()
Weld = nil
end

ReplicateSet:FireAllClients('RemoveEmoteSync', { MainChar =
Character; })
TriggerHumanoid(Character, { RS = 25; WS = 16; JP = 50; AR =
true; })

for _, v in assets do
if v and v.Parent then
v:Destroy()
end
end
end)
AnimationService:playAnimation(Character, Anim, 0)

ReplicateSet:FireAllClients('AddEmoteSync', { MainChar = Character; })

wait()

TriggerHumanoid(Character, { RS = 0; WS = 0; JP = 0; AR = true; })
end,

-- Add the same check for each other emote function, ensuring the stun state
is verified
Owl = function(Player: Player, Anim: Animation)
local Character = Player.Character

-- Check if character is stunned before proceeding


if CheckIfStunned(Character) then return end
local Humanoid: Humanoid = Character.Humanoid
local HumRP: BasePart = Character.HumanoidRootPart

local Track: AnimationTrack =


AnimationService:getAnimationTrack(Character, Anim)

local assets = {}
Track.Stopped:Once(function()
TriggerHumanoid(Character, { RS = 25; WS = 16; JP = 50; AR =
true; })

for _, v in assets do
if v and v.Parent then
v:Destroy()
end
end
end)
AnimationService:playAnimation(Character, Anim)

table.insert(assets, SoundsModule:PlaySound(script.Owl.Music, HumRP, 1,


1))

wait()

TriggerHumanoid(Character, { RS = 0; WS = 0; JP = 0; AR = true; })
end,

-- IMPORTANT --
and add a check for all other emotions, like Mad, Dab me Up, owl and etc

You might also like