My Problem is that the animation I labelled as “FireballThrow” and the fireball projectile does play in the Roblox Studio environment, HOWEVER in a real game it doesn’t execute properly, only the projectile is successful
Here is my original code:
My Local Script (Below) in the StarterPack folder
local player = game.Players.LocalPlayer
local cooldown = false
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local mouse = player:GetMouse()
UIS.InputBegan:Connect(function(Input,gpe)
if Input.KeyCode == Enum.KeyCode.E and not gpe and not cooldown then
print("Skill Thrown")
cooldown = true
local animation = player.Character:WaitForChild("Humanoid"):LoadAnimation(script.FireballThrow)
animation:Play()
wait(.5)
RS.ThrowRemote:FireServer(mouse.Hit.p)
game.Debris:AddItem(animation,2)
wait(2)
cooldown = false
end
end)
And my server side script (Below) in ServerScriptService:
local remote = game.ReplicatedStorage.ThrowRemote
remote.OnServerEvent:Connect(function(player,MousePosition)
local fireball = game.ReplicatedStorage.Fireball:Clone()
fireball.Parent = workspace
fireball.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2)
local NewForce = Instance.new("BodyForce")
NewForce.Force = Vector3.new(0,workspace.Gravity * fireball:GetMass(),0)
NewForce.Parent = fireball
fireball.Velocity = CFrame.new(player.Character.HumanoidRootPart.Position,MousePosition).LookVector * 70
fireball.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not hit:IsDescendantOf(player.Character) then
hit.Parent.Humanoid.Health -= 50 -- You can choose how much damage they take
fireball:Destroy()
end
wait(4)
fireball:Destroy()
end)
end)
I used remoteEvents to trigger the server side script.
The animation for the fireball is nested in the local script (If thats the right word), and the remoteEvents and fireball model are in ReplicatedStorage
I’ve tried reaching out to other people who have made other functions to the code that work BUT the animation still doesn’t work which is kind of the main thing. Most I’ve managed to fiddle around with is getting the animation to run within Roblox Studio itself.
I’m not too advanced with Lua as I’ve been teaching myself here and there and wanted to make a game for myself to have on my portfolio of things I’ve created. Any help with explaining where I may be going wrong would be much appreciated
Nafis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.