-
What do you want to achieve? I want there to be a cooldown reload for the taser
-
What is the issue? There’s no delay for the reload for this taser
- What solutions have you tried so far? Tried editing the TimeVal but the clicking R 2x overrides it.
ServerScriptServices
Tazer Server
game.ReplicatedStorage.TazerEvents:WaitForChild("event1").OnServerEvent:connect(function(plr,mtarg,Tool)
local v = (mtarg - Tool.Cart.Position).unit
local v2 = ((mtarg + Vector3.new(0,-1.5,0)) - Tool.Cart.Position).unit
local spawnPos = Tool.Cart.Position
spawnPos = spawnPos + (v * 2)
local barb_1 = Instance.new("Part")
barb_1.Position = spawnPos
barb_1.FormFactor = 3
barb_1.Size = Vector3.new(1,1,1)
barb_1.Velocity = v * 500--1000
barb_1.BrickColor = BrickColor.new(194)
barb_1.BottomSurface = 0
barb_1.TopSurface = 0
barb_1.Name = "TaserBarb"
barb_1.Elasticity = 0
barb_1.Reflectance = 0.1
barb_1.Friction = 1
Tool.BarbMesh:clone().Parent = barb_1
local sc = script.BarbScript:clone()
sc.Parent = barb_1
sc.Disabled = false
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,150,0)
force.Parent = barb_1
barb_1.Parent = game.Workspace
local barb_2 = barb_1:clone()
barb_2.Position = spawnPos + (v2 * 2) + Vector3.new(0,-0.5,0)
barb_2.Velocity = v2 * 500
barb_2.BodyForce.force = Vector3.new(0,150,0)
barb_2.Parent = game.Workspace
Tool.BlastDoor1.Transparency = 1
Tool.BlastDoor2.Transparency = 1
local function BarbTouched(hit,barb)
if hit == nil then return end
if hit.Parent == nil then return end
if hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Zombie") ~= nil then
if hit.Parent.Name == plr.Name then return end
if hit.Parent:FindFirstChild("OverrideScript") == nil then
local s = script.OverrideScript:clone()
s.Parent = hit.Parent
game.ReplicatedStorage.TazerEvents:WaitForChild("event1"):FireClient(plr,hit.Parent)
s.Disabled = false
end
barb:Remove()
elseif hit.CanCollide == true then
barb:Remove()
end
end
barb_1.Touched:connect(function(hit)
--game.ReplicatedStorage.event1:FireClient(plr,"BarbTouched",hit,barb_1)
BarbTouched(hit,barb_1)
end)
barb_2.Touched:connect(function(hit)
--game.ReplicatedStorage.event1:FireClient(plr,"BarbTouched",hit,barb_2)
BarbTouched(hit,barb_2)
end)
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event2").OnServerEvent:connect(function(plr,target)
target:WaitForChild("OverrideScript"):Destroy()
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event3").OnServerEvent:connect(function(plr,target)
local st = script.OverrideScript:clone()
st.Disabled = false
st.Parent = target
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event4").OnServerEvent:connect(function(plr,hit)
if hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Zombie") ~= nil then
local s = script.DriveStunScript:clone()
s.Parent = hit.Parent
s.Disabled = false
end
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event5").OnServerEvent:connect(function(plr,Tool)
local electrictextures = {"http://www.roblox.com/asset/?id=109201383", "http://www.roblox.com/asset/?id=109201366", "http://www.roblox.com/asset/?id=109201474", "http://www.roblox.com/asset/?id=109201980", "http://www.roblox.com/asset/?id=109202011"}
local function GetElectricTexture()
local r = math.random(1,#electrictextures)
return electrictextures[r]
end
Tool.Electric.Decal.Texture = GetElectricTexture()
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("keybindevent").OnServerEvent:connect(function(plr,key,Tool)
if key == "y" then
if Tool.Lamp.Light.Enabled == true then
Tool.Lamp.Light.Enabled = false
else
Tool.Lamp.Light.Enabled = true
end
end
if key == "r1" then
Tool.Cart.Transparency = 1
Tool.Cart.CanCollide = false
Tool.BlastDoor1.Transparency = 1
Tool.BlastDoor1.CanCollide = false
Tool.BlastDoor2.Transparency = 1
Tool.BlastDoor2.CanCollide = false
end
if key == "r2" then
Tool.Cart.Transparency = 0
Tool.Cart.CanCollide = true
Tool.BlastDoor1.Transparency = 0
Tool.BlastDoor1.CanCollide = true
Tool.BlastDoor2.Transparency = 0
Tool.BlastDoor2.CanCollide = true
end
end)
Script inside the taser
Taser LocalScript
game.ReplicatedStorage.TazerEvents:WaitForChild("event1").OnServerEvent:connect(function(plr,mtarg,Tool)
local v = (mtarg - Tool.Cart.Position).unit
local v2 = ((mtarg + Vector3.new(0,-1.5,0)) - Tool.Cart.Position).unit
local spawnPos = Tool.Cart.Position
spawnPos = spawnPos + (v * 2)
local barb_1 = Instance.new("Part")
barb_1.Position = spawnPos
barb_1.FormFactor = 3
barb_1.Size = Vector3.new(1,1,1)
barb_1.Velocity = v * 500--1000
barb_1.BrickColor = BrickColor.new(194)
barb_1.BottomSurface = 0
barb_1.TopSurface = 0
barb_1.Name = "TaserBarb"
barb_1.Elasticity = 0
barb_1.Reflectance = 0.1
barb_1.Friction = 1
Tool.BarbMesh:clone().Parent = barb_1
local sc = script.BarbScript:clone()
sc.Parent = barb_1
sc.Disabled = false
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,150,0)
force.Parent = barb_1
barb_1.Parent = game.Workspace
local barb_2 = barb_1:clone()
barb_2.Position = spawnPos + (v2 * 2) + Vector3.new(0,-0.5,0)
barb_2.Velocity = v2 * 500
barb_2.BodyForce.force = Vector3.new(0,150,0)
barb_2.Parent = game.Workspace
Tool.BlastDoor1.Transparency = 1
Tool.BlastDoor2.Transparency = 1
local function BarbTouched(hit,barb)
if hit == nil then return end
if hit.Parent == nil then return end
if hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Zombie") ~= nil then
if hit.Parent.Name == plr.Name then return end
if hit.Parent:FindFirstChild("OverrideScript") == nil then
local s = script.OverrideScript:clone()
s.Parent = hit.Parent
game.ReplicatedStorage.TazerEvents:WaitForChild("event1"):FireClient(plr,hit.Parent)
s.Disabled = false
end
barb:Remove()
elseif hit.CanCollide == true then
barb:Remove()
end
end
barb_1.Touched:connect(function(hit)
--game.ReplicatedStorage.event1:FireClient(plr,"BarbTouched",hit,barb_1)
BarbTouched(hit,barb_1)
end)
barb_2.Touched:connect(function(hit)
--game.ReplicatedStorage.event1:FireClient(plr,"BarbTouched",hit,barb_2)
BarbTouched(hit,barb_2)
end)
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event2").OnServerEvent:connect(function(plr,target)
target:WaitForChild("OverrideScript"):Destroy()
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event3").OnServerEvent:connect(function(plr,target)
local st = script.OverrideScript:clone()
st.Disabled = false
st.Parent = target
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event4").OnServerEvent:connect(function(plr,hit)
if hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Zombie") ~= nil then
local s = script.DriveStunScript:clone()
s.Parent = hit.Parent
s.Disabled = false
end
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("event5").OnServerEvent:connect(function(plr,Tool)
local electrictextures = {"http://www.roblox.com/asset/?id=109201383", "http://www.roblox.com/asset/?id=109201366", "http://www.roblox.com/asset/?id=109201474", "http://www.roblox.com/asset/?id=109201980", "http://www.roblox.com/asset/?id=109202011"}
local function GetElectricTexture()
local r = math.random(1,#electrictextures)
return electrictextures[r]
end
Tool.Electric.Decal.Texture = GetElectricTexture()
end)
game.ReplicatedStorage.TazerEvents:WaitForChild("keybindevent").OnServerEvent:connect(function(plr,key,Tool)
if key == "y" then
if Tool.Lamp.Light.Enabled == true then
Tool.Lamp.Light.Enabled = false
else
Tool.Lamp.Light.Enabled = true
end
end
wait(2)
if key == "r1" then
wait(5)
Tool.Cart.Transparency = 1
Tool.Cart.CanCollide = false
wait(0.1)
Tool.BlastDoor1.Transparency = 1
Tool.BlastDoor1.CanCollide = false
wait(0.1)
Tool.BlastDoor2.Transparency = 1
Tool.BlastDoor2.CanCollide = false
wait(0.1)
end
wait (3)
if key == "r2" then
Tool.Cart.Transparency = 0
Tool.Cart.CanCollide = true
wait(0.1)
Tool.BlastDoor1.Transparency = 0
Tool.BlastDoor1.CanCollide = true
wait(0.1)
Tool.BlastDoor2.Transparency = 0
Tool.BlastDoor2.CanCollide = true
wait(0.1)
end
end)