Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I put my own animation into this script?

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

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)

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.