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

How do I make an animation play on another character when I click and after I say a string?

Asked by 4 years ago

My Local Script

wait()
local Player = game:GetService("Players").LocalPlayer -- Game gets access to "Players" asset and then takes a local player from it (it's basically the same but more organized).
local char = Player.Character
local Mouse = Player:GetMouse()
local cooldown = 0
local replicatedstorage = game:GetService("ReplicatedStorage")

Player.Chatted:Connect(function(message)
    message = message:lower()
    if message == "Burn" then
        game.ReplicatedStorage.Pain:FireServer(3444669792,Mouse.hit)
        wait(1.62)
    end
end)

My Server Script.

game:GetService("ReplicatedStorage"):FindFirstChild("Pain").OnServerEvent:Connect(function(player,animationID,Mouse)
    Mouse.Button1Down:Connect(function(hit)
    local humanoid = Mouse.hit.Parent:FindFirstChild("Humanoid")

    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID

    local loadedAnimation = humanoid:LoadAnimation(animation)
    loadedAnimation:Play()
    wait(2.65)
    loadedAnimation:Stop()
    loadedAnimation:Destroy()

    end)
end)

Not outputting errors, please someone help me and tell me how to fix.

0
For those who can't see my full line of text on the First line of my Server script, looks like this JayShepherdMD 147 — 4y
0
game:GetService("ReplicatedStorage"):FindFirstChild("Pain").OnServerEvent:Connect(function(player,animationID,Mouse) JayShepherdMD 147 — 4y
0
rather than connecting the Mouse event, why not use Mouse.Target and use FindFirstChild to check if it exists? aipiox123 1 — 4y
0
Correct me if I'm wrong but you can't use .Chatted:Connect(function() on the client. Just do it all on the server. namespace25 594 — 4y

Answer this question