so i want to make a script that counts time and share the time across the server. However, for some reason it doesn’t work as intended.
Here is the script that counts the time:
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local CombatRelated = plr:WaitForChild("CombatRelated")
local CanPerformAttack = CombatRelated.CanPerformAttack
local BlockEnd = game.ReplicatedStorage.Events.Katana.Block.BlockEndCool
local DidBlock = false
local Time = 0
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.B then
if CanPerformAttack.Value == true then
DidBlock = true
while DidBlock == true do
wait(0.1)
Time = Time + 0.1
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.B then
if DidBlock == true then
DidBlock = false
BlockEnd:FireServer(plr,Time)
Time = 0
end
end
end)
end
end
end
end)
and here is the script that receives it:
local BlockEnd = game.ReplicatedStorage.Events.Katana.Block.BlockEndCool
BlockEnd.OnServerEvent:Connect(function(plr,Time)
print(plr, Time)
end)
but for some reason the output is
Temeraire149 Temeraire149
Thanks,
Tem