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)
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)