You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I’ve been having this problem that allows users to use autoclicks on an ingame weapon -
What is the issue? Include screenshots / videos if possible!
Switching between weapons or just simply running two animations will remove the cooldown between clicks. You also don’t have to do either, and are just able to spam…
-
What solutions have you tried so far? Did you look for solutions on the Creator Hub?
Checked for clientside and serversided attributes set, tried switching when different scripts fire.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I have these 2 scripts that are used
wait(3)
print("ShootingLoaded")
local workspace = game:GetService("Workspace")
local camera = workspace.CurrentCamera
local debris = game:GetService("Debris")
local RP = game:GetService("ReplicatedStorage")
local arms = require(RP.ModuleScripts.Arms)
local SC = RP:WaitForChild("RemoteEvents").ShootingClient
local S = RP:WaitForChild("RemoteEvents").Shooting
local animator = arms.viewmodel:WaitForChild("Humanoid"):FindFirstChildWhichIsA("Animator")
local shootingSyringe = animator:LoadAnimation(script.ShootingSyringe)
shootingSyringe.Looped = false
local attributeChange = RP:WaitForChild("RemoteEvents").AttributeChange
local soundService = game:GetService("SoundService")
local SyringeGunSounds = soundService.Sounds.SyringeGun
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
player.CharacterAdded:Connect(function(char)
character = char
end)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(inp)
if inp.UserInputType == Enum.UserInputType.MouseButton1
and player:GetAttribute("currentWeapon") == 1
and player:GetAttribute("changeAllowed") == true then
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
player:SetAttribute("changeAllowed", false)
player.CharacterAdded:Connect(function(char)
character = char
end)
local viewmodel = arms.viewmodel
local syringe = arms.viewmodel.HumanoidRootPart.Handle
local mouseLocation = UIS:GetMouseLocation()
local ray = camera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
local rayOrigin = ray.Origin
local rayDirection = ray.Direction * 200
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {character, arms.viewmodel}
rayParams.IgnoreWater = true
local rayResult = workspace:Raycast(rayOrigin, rayDirection, rayParams)
local hitPos = rayResult and rayResult.Position or (rayOrigin + rayDirection)
if rayResult then
print(rayResult.Instance)
local gui = player:WaitForChild("PlayerGui")
local Selected = gui:FindFirstChild("Selected")
if not Selected then return end
local AmmoLabel = Selected:FindFirstChild("Ammo")
if not AmmoLabel then return end
shootingSyringe:Stop()
shootingSyringe:Play()
task.spawn(function()
SyringeGunSounds.GunShot:Play()
task.wait(0.6)
SyringeGunSounds.SyringeReload:Play()
task.wait(0.45)
SyringeGunSounds.LeverFlip:Play()
end)
SC:Fire(1, shootingSyringe.Length)
local tube = arms.viewmodel.HumanoidRootPart:WaitForChild("Handle").Model:WaitForChild("tube")
S:FireServer(rayResult.Instance, 15, tube.Rotation, "1", rayResult.Position)
local model = arms.viewmodel.HumanoidRootPart:WaitForChild("Handle"):WaitForChild("Model")
model.currentAmmo.Value -= 1
AmmoLabel.Text = tostring(model.currentAmmo.Value) .. "/" .. tostring(model.AmmoMax.Value)
task.delay(shootingSyringe.Length, function()
player:SetAttribute("changeAllowed", true)
shootingSyringe:Stop()
print(model:GetChildren())
local WCA = model:WaitForChild("currentAmmo")
if WCA.Value == 0 then
WCA.Value = model.AmmoMax.Value
AmmoLabel.Text = tostring(WCA.Value) .. "/" .. tostring(model.AmmoMax.Value)
end
end)
else
player:SetAttribute("changeAllowed", true)
end
end
end)
wait(3)
print("weaponChangeLoaded")
local RP = game:GetService("ReplicatedStorage")
local weaponChange = RP:WaitForChild("RemoteEvents").WeaponChange
local weaponsFolder = RP:WaitForChild("Weapons")
local player = game.Players.LocalPlayer
local character = workspace:WaitForChild("Viewmodel")
local char = game.Players.LocalPlayer.Character
local UIS = game:GetService("UserInputService")
local currentSelected = character:GetAttribute("CurrentWeapon")
local animator = character:FindFirstChildWhichIsA("Humanoid"):FindFirstChildWhichIsA("Animator")
local attributeChange = RP:WaitForChild("RemoteEvents").AttributeChange
local SC = RP:WaitForChild("RemoteEvents").ShootingClient
-- // SYRINGE
local SyringeTrack = animator:LoadAnimation(script.Syringe.Syringe)
SyringeTrack.Looped = false
local SyringeInspecting = animator:LoadAnimation(script.Syringe.InspectingSyringe)
SyringeInspecting.Looped = false
local SyringeIdle = animator:LoadAnimation(script.Syringe.SyringeIdle)
SyringeIdle.Looped = true
local idleFolder = {SyringeIdle}
local mouse = player:GetMouse()
mouse.Icon = script.Crosshair.Texture
--// WATCH INTERACTIONS
local WatchInspecting = animator:LoadAnimation(script.Watch.InspectingWatch)
WatchInspecting.Looped = false
local NeverOutTrack = animator:LoadAnimation(script.Watch.NeverOut)
NeverOutTrack.Looped = false
local currentWeapon = 1
local TextChatService = game:GetService("TextChatService")
player.CharacterAdded:Connect(function(char)
char = game.Players.LocalPlayer.Character
end)
local changeWeapon = function(weapon, player)
for i,v in idleFolder do
if v then
v:Stop()
end
end
local character = workspace:WaitForChild("Viewmodel")
local playerGui = player.PlayerGui
local Selected = playerGui:WaitForChild("Selected")
for i,v in character:WaitForChild("HumanoidRootPart"):GetChildren() do
if v.Name == "Handle" then
v:Destroy()
end
end
local newClone = weapon:Clone()
newClone.Parent = character:WaitForChild("HumanoidRootPart")
local handle = newClone
local rightArm = character:WaitForChild("HumanoidRootPart")
local weldConstraint = Instance.new("Motor6D", rightArm)
weldConstraint.Name = "Handle"
weldConstraint.Part0 = rightArm
weldConstraint.Part1 = handle
weldConstraint.C0 = weapon.Model.Value.Value
Selected.ImageLabel.Image = weapon.Model.Id.Value
Selected.Shadow.Image = weapon.Model.Id.Value
Selected.TextLabel.Text = weapon.Model:WaitForChild("Name").Value
Selected.Ammo.Text = tostring(weapon.Model:WaitForChild("currentAmmo").Value) .. "/" .. tostring(weapon.Model:WaitForChild("AmmoMax").Value)
end
local tool = nil
local allowedSwitch = true
for i,v in weaponsFolder:GetChildren() do
if v.Model:WaitForChild("Name").Value == "Syringe Gun" then
tool = v
end
end
changeWeapon(tool, player)
weaponChange:FireServer("syringeGun", player:GetAttribute("SessionKey"))
SyringeTrack:Stop()
SyringeTrack:Play()
task.delay(SyringeTrack.Length - 0.1, function()
SyringeTrack:Stop()
if currentWeapon == 1 then
SyringeIdle:Play()
end
end)
local Arms = require(RP.ModuleScripts.Arms)
local HRGui = Arms.viewmodel.RightArm.Watch.Screen.SurfaceGui
TextChatService.OnIncomingMessage = function(message)
if message.TextSource and message.TextSource.UserId then
if message.TextSource.UserId == player.UserId then
if message.Status == Enum.TextChatMessageStatus.Success then
if message.Text == "hold your horses" and player:GetAttribute("changeAllowed") == true then
allowedSwitch = false
currentWeapon = 2
allowedSwitch = true
weaponChange:FireServer("hold your horses", player:GetAttribute("SessionKey"))
script.SoundEffect.Holdyour:Stop()
script.SoundEffect.Holdyour:Play()
for i,v in weaponsFolder:GetChildren() do
if v.Model:WaitForChild("Name").Value == "Hold" then
tool = v
end
end
changeWeapon(tool, player)
player:SetAttribute("changeAllowed", true)
end
end
end
end
end
UIS.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.One and currentWeapon ~= 1 and player:GetAttribute("changeAllowed") == true and allowedSwitch == true then
player:SetAttribute("changeAllowed", false)
allowedSwitch = false
currentWeapon = 1
task.delay(0.1, function()
allowedSwitch = true
end)
weaponChange:FireServer("syringeGun", player:GetAttribute("SessionKey"))
SyringeTrack:Stop()
SyringeTrack:Play()
for i,v in weaponsFolder:GetChildren() do
if v.Model:WaitForChild("Name").Value == "Syringe Gun" then
tool = v
end
end
changeWeapon(tool, player)
task.delay(SyringeTrack.Length - 0.1, function()
SyringeTrack:Stop()
player:SetAttribute("changeAllowed", true)
if currentWeapon == 1 then
SyringeIdle:Play()
end
end)
elseif inp.KeyCode == Enum.KeyCode.Two and currentWeapon ~= 2 and player:GetAttribute("changeAllowed") == true and allowedSwitch == true then
allowedSwitch = false
player:SetAttribute("changeAllowed", false)
currentWeapon = 2
allowedSwitch = true
weaponChange:FireServer("hold your horses", player:GetAttribute("SessionKey"))
script.SoundEffect.Holdyour:Stop()
script.SoundEffect.Holdyour:Play()
for i,v in weaponsFolder:GetChildren() do
if v.Model:WaitForChild("Name").Value == "Hold" then
tool = v
end
end
changeWeapon(tool, player)
task.delay(0.1, function()
player:SetAttribute("changeAllowed", true)
end)
elseif inp.KeyCode == Enum.KeyCode.F and currentWeapon == 1 and player:GetAttribute("changeAllowed") == true and allowedSwitch == true then
player:SetAttribute("changeAllowed", false)
SyringeIdle:Stop()
allowedSwitch = false
SyringeInspecting:Play()
task.delay(SyringeInspecting.Length, function()
player:SetAttribute("changeAllowed", true)
SyringeIdle:Play()
allowedSwitch = true
end)
elseif inp.KeyCode == Enum.KeyCode.G and player:GetAttribute("changeAllowed") == true and allowedSwitch == true then
player:SetAttribute("changeAllowed", false)
idleFolder[currentWeapon]:Stop()
allowedSwitch = false
local random = math.random(1,2)
if random == 1 then
HRGui:WaitForChild("Another").Visible = false
WatchInspecting:Play()
WatchInspecting.Ended:Wait()
else
HRGui:WaitForChild("Another").Visible = true
HRGui:WaitForChild("Another").Image = "rbxassetid://87232808870842"
NeverOutTrack:Play()
task.delay(NeverOutTrack.Length - 0.6, function()
HRGui:WaitForChild("Another").Visible = false
script.SoundEffect.GlassBreak:Stop()
script.SoundEffect.GlassBreak:Play()
end)
NeverOutTrack.Ended:Wait()
end
player:SetAttribute("changeAllowed", true)
allowedSwitch = true
idleFolder[currentWeapon]:Play()
end
end)
player.CharacterAdded:Connect(function()
changeWeapon(tool, player)
weaponChange:FireServer("syringeGun", player:GetAttribute("SessionKey"))
SyringeTrack:Stop()
SyringeTrack:Play()
task.delay(SyringeTrack.Length - 0.1, function()
SyringeTrack:Stop()
if currentWeapon == 1 then
SyringeIdle:Play()
end
end)
end)
SC.Event:Connect(function(gun, time)
if gun == 1 then
print("IdleStoped")
SyringeIdle:Stop()
task.wait(time)
SyringeIdle:Play()
print(SyringeIdle.IsPlaying)
print("IdlePlayed")
elseif gun == "Admin" then
SyringeIdle:Stop()
elseif gun == "AdminDone" then
idleFolder[currentWeapon]:Play()
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
