Im making a script where whenever you click q a block goes infront of you and there is a cooldown, it works perfect in rblx studio but not game can anyone help? here is script there is more than one script here: all my code
local eventq = game:GetService("ReplicatedStorage").Remotes.eventq
game:GetService("Players").PlayerAdded:Connect(function(plr)
local cooldown = Instance.new("NumberValue")
cooldown.Value = tick()
cooldown.Name = "Cooldown"
cooldown.Parent = plr
end)
eventq.OnServerEvent:Connect(function(player, cooldown)
if tick() - player.Cooldown.Value > cooldown then
player.Cooldown.Value = tick()
end
end)
local UIS = game:GetService("UserInputService")
local hotkey = Enum.KeyCode.Q
local cooldown = 10
local event = game:GetService("ReplicatedStorage").Remotes.eventq
local fp = game.Workspace.FIRE
local plr = game:GetService("Players").LocalPlayer
UIS.InputBegan:Connect(function(input)
if input.KeyCode == hotkey then
if tick() - plr.Cooldown.Value > cooldown then
local fpl = plr.Character:WaitForChild("HumanoidRootPart").Position
fp.CFrame = CFrame.new(fpl)
fp.ParticleEmitter.Enabled = true
event:FireServer(cooldown)
local timer = 0
local lastTime = tick()
while timer < cooldown do -- 10 for max amount of seconds
timer += tick()-lastTime
task.wait()
fp.CFrame = CFrame.new(fpl)
end
fp.CFrame = CFrame.new(1721.725, 2511.404, -1099.142)
fp.ParticleEmitter.Enabled = false
end
end
end)
local player = game:GetService("Players").LocalPlayer
local value = player:WaitForChild("Cooldown")
local gui = script.Parent
local cooldown = 10
while wait(0.3) do
local last = tick() - value.Value
if last > cooldown then last = cooldown end
local change = 1 - (last/cooldown)
gui:TweenSize(UDim2.new(1,0,change,0),"In","Linear", 0.3)
end
and no there isnt any errors in game or studio
