how to make a clicking cool down when you click the sky ?
Asked by
4 years ago Edited 4 years ago
A few hours ago i've made a pistol script (keep in mind that for the pistol script i used mouse.Target) but i met a error along the way in which i can't figure out a solution, so basically a pistol has a cool down, right ? it won't just shoot out bullets like a rifle so i made a cool down IF the mouse.Target is either terrain or a player, but what about the sky, the sky is equal to nil, how do i add a cool down if my mouse is pointing at the sky ? (debounce just messes up the script)
01 | local handle = script.Parent.Handle |
02 | local tool = script.Parent |
03 | local player = game.Players.LocalPlayer |
04 | local gui = player:WaitForChild( "PlayerGui" ) |
05 | local screenGui = gui:WaitForChild( "ScreenGui" ) |
06 | local TextLabel = screenGui:WaitForChild( "Ammo" ) |
07 | local mouse = player:GetMouse() |
10 | local serivce = game:GetService( "UserInputService" ) |
11 | local oldIcon = mouse.Icon |
17 | tool.Equipped:Connect( function () |
19 | TextLabel.Visible = true |
22 | tool.Activated:Connect( function () |
23 | if tool.Enabled = = true then |
26 | if mouse.Target.Parent:FindFirstChild( "Humanoid" ) then |
27 | script.Parent.Damage:FireServer(mouse.Target) |
43 | TextLabel.Text = Ammo 1.. "/" ..mxAm |
45 | tool.Unequipped:Connect( function () |
47 | TextLabel.Visible = false |
50 | serivce.InputBegan:Connect( function (key) |
51 | if key.KeyCode = = Enum.KeyCode.R and Ammo 1 ~ = mxAm then |