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

How can i make a player do an Slice animation in script?

Asked by 4 years ago
Edited 4 years ago

Heres the local script

I hope its right, (tell me if its not)

So i want it to play an animation in the script after i press E

Local Script:

https://gyazo.com/4e7bf07c141ca5b4970cee40aa95fb25

local Player = game:GetService("Players")

local rp = game:GetService("ReplicatedStorage")
local Lancer = rp:WaitForChild("Lancer")


local UIS = game:GetService("UserInputService")

local debounce = false
local cooldown = 1

UIS.InputBegan:Connect(function(input,isTyping)
    if isTyping then
        return

    elseif input.KeyCode == Enum.KeyCode.E and debounce == false then
        debounce = true

        Lancer:FireServer()



    end
end)

Lancer.OnClientEvent:Connect(function()

    wait(cooldown)
    debounce = false
end)

I want it to fire the script in serverscriptservice

this is what i have rn

    local rp = game:GetService("ReplicatedStorage")
    local Lancer = rp:WaitForChild("Lancer")
0
^^ thats normal script themaxogamer 58 — 4y
0
Are you trying to change the player's animation via Server Script? LikeToScript 108 — 4y
0
no lets say a slice animation themaxogamer 58 — 4y
0
Well then, try using :LoadAnimation() LikeToScript 108 — 4y

1 answer

Log in to vote
1
Answered by
oilkas 364 Moderation Voter
4 years ago
Edited 4 years ago

Hopefully this should work:

local rp = game:GetService("ReplicatedStorage")
local Lancer = rp:WaitForChild("Lancer")
local Animation = AnimationFolderHere:WaitForChild("AnimationNameHere") -- Find the animation

Lancer.OnServerEvent:Connect(function(Player) -- Listen to event fire
    local Character = Player.Character -- Get the player's character
    local Humanoid = Character:FindFirstChild("Humanoid")
    local LoadedAnimation = Humanoid:LoadAnimation(Animation) -- Load the animation
    LoadedAnimation:Play() -- Play the animation
    Lancer:FireClient(Player)
end)
0
Hi tysm it helped script works but it only plays once https://gyazo.com/2d72010dd31b46ae69f101513bfb643f what can be the problem themaxogamer 58 — 4y
0
Hi tysm it helped script works but it only plays once https://gyazo.com/2d72010dd31b46ae69f101513bfb643f what can be the problem themaxogamer 58 — 4y
0
Hmmm oilkas 364 — 4y
0
The problem is that client is not fired to set the debounce to false, see the updated script. oilkas 364 — 4y
Ad

Answer this question