Im making a skill system and im not sure whats wrong in this script, can anyone tell me?
local EventE = game:GetService("ReplicatedStorage").Events.EventE
game:GetService("Players").PlayerAdded:Connect(function(player)
local cooldown = Instance.new("NumberValue")
cooldown.Value = tick()
cooldown.Name = "Cooldown"
cooldown.Parent = player
end)
EventE.OnServerEvent:Connect(function(player, cooldown)
if tick() - player.Cooldown.Value > cooldown then
--Here we will put tje actual ability code
player.Cooldown.Value = tick()
end
end)
local EventE = game:GetService("ReplicatedStorage").Events.EventE
game:GetService("Players").PlayerAdded:Connect(function(player)
local cooldown = Instance.new("NumberValue")
cooldown.Value = tick()
print("Cooldown's Value: "..cooldown.Value)
cooldown.Name = "Cooldown"
cooldown.Parent = player
end)
EventE.OnServerEvent:Connect(function(player, cooldown)
print(cooldown)
if tick() - player.Cooldown.Value > cooldown then
--Here we will put tje actual ability code
player.Cooldown.Value = tick()
end
end)
i already fired a remote event in another scrpt
Heres the script
local UIS = game:GetService("UserInputService")
local hotkey = Enum.KeyCode.E
local cooldown = 5
local event = game:GetService("ReplicatedStorage").Events.EventE
local player = game:GetService("Players").LocalPlayer
UIS.InputBegan:Connect(function(input)
if input.KeyCode == hotkey then
if tick() - player.Cooldown.Value > cooldown then
event:FireServer()
end
end
end)