My event isnt being picked infact everything below the keycode isnt being picked up
local CombatE = game.ReplicatedStorage:WaitForChild("CombatEvent")
local Combo = 1
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, IsTyping)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Detected mouseclick")
if Combo == 1 then
CombatE:FireServer(Player, Combo)
Combo = 2
elseif Combo == 2 then
CombatE:FireServer(Player, Combo)
Combo = 3
elseif Combo == 3 then
CombatE:FireServer(Player, Combo)
Combo = 4
elseif Combo == 4 then
CombatE:FireServer(Player, Combo)
Combo = 5
elseif Combo == 5 then
CombatE:FireServer(Player, Combo)
Combo = 1
end
end
end)
1 Like
The first thing I see is that you do not pass in the Player yourself, it does so automatically, you just have to pass in the Combo, so CombatE:FireServer(Combo)
. Also what do you mean isn’t being picked up, Detected mouseclick
isn’t printing?
3 Likes
Also a lot of this code is unnecessary.
You can just check if Combo < 5
, and fire the server with Combo, and add 1 onto Combo, otherwise if it is 5, fire the server and set Combo to 1.
2 Likes
Or better yet, just do this
local CombatE = game.ReplicatedStorage:WaitForChild("CombatEvent")
local Combo = 1
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, IsTyping)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Detected mouseclick")
CombatE:FireServer(Combo)
Combo += 1
if Combo == 6 then Combo = 1 end
end
end)
3 Likes
its printing but anything below that wouldnt run i have my event in replicate storage
I used a print to figure out if anything below the event would run and nothing did
so far ive had no errors
1 Like
I think it could be that you were passing in the Player with the Combo, although that would’ve errored. Try out what I did and if it doesn’t work either, show me your OnServerEvent for that CombatE event
1 Like
it didnt work
heres the OnServerEvent
1 Like
Okay I think the issue is that the parameters are wrong, your function(Combo)
should be function(Player,Combo)
2 Likes
I forgot to mention that the fire server script is a local script in starter pack and the onserverevent scrip is in serverscriptservice
1 Like
I tried that before to
I have no idea why it’s not working
1 Like
Wait wait, try removing the local Combo = 1
from the server script, if it doesn’t work either, I think something may be wrong with the code, so if that doesn’t work, just commenting all the code in your OnServerEvent and just do a print(Combo)
2 Likes