I am trying to make a combat system,and have heard that the best way to do so is by making the server deal the damage/magnitude while the client does the animations, sounds, etc. However, when I try to use :FireServer() with it to connect the client to the server, it doesn't work. The error I always receive is "51: attempt to index upvalue 'ServerCombat' (a nil value)"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerCombat = ReplicatedStorage:WaitForChild("ServerCombat", 2)
local UserInputService = game:GetService("UserInputService")
-- A counter to help decide which animation to play
local swingCount = 0
local swingCount2 = 0
local currentSwingAnimation
--Animation for the Light attack combo sequence.
UserInputService.InputBegan:connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode[Key] and Debounce then
swingCount = swingCount + 1
-- cancel any animation currently playing
if currentSwingAnimation then
currentSwingAnimation:Stop()
currentSwingAnimation = nil
end
if swingCount == 1 then
-- play the first animation
Debounce = false
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationId1
currentSwingAnimation = Humanoid:LoadAnimation(Animation)
currentSwingAnimation.Looped = false
currentSwingAnimation:Play()
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
ServerCombat:FireServer()
wait(.35)
currentSwingAnimation:Stop()
Debounce = true
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
elseif swingCount == 2 then
-- play the second swing animation
Debounce = false
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationId2
currentSwingAnimation = Humanoid:LoadAnimation(Animation)
currentSwingAnimation.Looped = false
currentSwingAnimation:Play()
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
wait(.35)
currentSwingAnimation:Stop()
Debounce = true
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
print("Working!")

4 comments
I have fixed it. It was because I didn't add the RemoteEvent itself to call the server script. Also, That was the first thing I had tried, and the error I had with that was that it could potentially yield forever if I didn't add a value to it, so I put 2, Now I am trying to figure out why the damage part of the script isn't working. But thank you for the help!
Nice! I'm glad you figured it out.
Do a search in models for thienbao2109 - his FE Gun Kit is pretty good! Its one of the best I've come across - great examples and features.
Thanks for the advice!