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

How can I put my own animation into this script?

Asked by
hh9man 5
6 years ago

So i have a fireball script. This is the script used to fire it.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RemoteEvent = game.Workspace.Fired
local UIS = game:GetService("UserInputService")

local Debounce = false

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.R then wait(0.5)
        if Debounce == true then return end
        RemoteEvent:FireServer(Debounce)
    end
end)

Im trying to figure out how i could put my animation i made on to this to make it look like its being thrown when the fireball spawns in.

Right now im using this animation script with it to make it look like its being thrown, but I know that this is not a good way to do it, and that there may be a way for them to be combined into one script.

  Animation = Instance.new("Animation")
    Animation.Parent = game.Workspace
    Animation.AnimationId = "http://www.roblox.com/asset/?id=2019308824"
    local Player = game.Players.LocalPlayer
    local mouse = game.Players.LocalPlayer:GetMouse()
mouse.KeyDown:connect(function (key)
    for i, v in pairs(game.Players:GetChildren()) do
    if key == "r" then 
        local AnimationTrack = Player.Character.Humanoid:LoadAnimation(Animation)
            AnimationTrack:Play()
    end
    end
    end)

1 answer

Log in to vote
0
Answered by 6 years ago

Put your code under an OnServerEvent

Server code:

game.Workspace.Fired.OnServerEvent:Connect(function(plr)
    -- animating code
end)

Client code:

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

    if input.KeyCode == Enum.KeyCode.R then
        game.Workspace.Fired:FireServer()
    end
end)
0
So im assuming that the server code goes into serverscriptservice, and i put my animation script where you told me to, and i put the client code into starterplayerscripts. But now the fireball doesnt fire at all. And both scripts have errors in output, im not sure how to fix it. hh9man 5 — 6y
Ad

Answer this question