Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why Isn't the ServerScriptService adding the punch animation to the players morph?

Asked by 1 year ago

Hello Developers!

(Note: Scroll down the message to see more Info)

As the title says, I made a local script under StarterCharactersFolder which Is this:

--SERVICES--
local UIS = game:GetService("UserInputService")
local RP = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players")

--Attack CD--
local PrimaryCD, PrimaryCDCoolDown = false, 1

--Characters--
local LocalPlayer = Player:GetPlayerFromCharacter(script.Parent)
local Character = LocalPlayer.Character
local PlrRoot = LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or LocalPlayer.Character:FindFirstChild("Torso")
local NewChar = RP.NOOBS.Exclusive["Buddies Noob"]:Clone()
NewChar.Name = LocalPlayer.Name
LocalPlayer.Character =  NewChar
local RootPart = NewChar:FindFirstChild("HumanoidRootPart") or NewChar:FindFirstChild("Torso")
if RootPart and PlrRoot then
    RootPart.CFrame = PlrRoot.CFrame
end
NewChar.Parent = workspace
NewChar.Humanoid.DisplayName = "Buddies Noob"
NewChar.Animate.Enabled = true
script.Parent:Destroy()

--Combat--
UIS.InputBegan:Connect(function(Input)
    if Input.UserInputType == Enum.UserInputType.MouseButton1 then
        if not PrimaryCD then
            PrimaryCD = true
            RP.Events.PrimaryPunch:FireServer("Happy Punch")
            task.wait(PrimaryCDCoolDown)
            PrimaryCD = false
        end
    end
end)

Under the "Combat" Section allows the user to punch for every 1 second thanks to a RemoteEvent In ReplicatedStorage, This Is what the ServerScriptService Script looks like (Server-Script btw):

game.ReplicatedStorage.Events.PrimaryPunch.OnServerEvent:Connect(function(Player, HappyMove)
    if HappyMove == "Happy Punch" then
        local AnimID = "rbxassetid://11885330750"
        local HappyPunch = Instance.new("Animation")
        game:GetService("Debris"):AddItem(HappyPunch,1)
        HappyPunch.Parent = Player.Character.Torso
        HappyPunch.AnimationId = AnimID
        local HappyPlayerPunching = Player.Character.Humanoid:WaitForChild("Animator"):LoadAnimation(HappyPunch)
        HappyPlayerPunching:Play()
    end
end)

But for some whatever reason, the ServerScriptService Script cannot put the animation In the players morph, meaning I have to remove the morph script In order for the punching animation to play

Answer this question