would anyone have a solution to this? the guns are from toolbox, and work fine in studio testing, but there is just the normal mouse ingame
Could you perhaps attach some code
Yeah, i forgot to do that as im about to fall asleep. Ill send a reply/update tmrw. Not rlly sure exactly what to send tho, as it works fine in studio
local MOUSE_ICON = ârbxasset://textures/GunCursor.pngâ
local RELOADING_ICON = ârbxasset://textures/GunWaitCursor.pngâ
local Players = game:GetService(âPlayersâ)
local UserInputService = game:GetService(âUserInputServiceâ)
local Tool = script.Parent
local toolammo = Tool:WaitForChild(âCurrentAmmoâ)
local toolrecoil = Tool:WaitForChild(âCurrentRecoilâ)
local firefunction = Tool.fire
local reloadfunction = Tool.reload
local animatefunction = Tool.animate
local crouchfunction = Tool.crouch
local meleefunction = Tool.melee
local hitmarkerfunction = Tool.hitmarker
local hitmarkerframes = 0
local hitmarkerframesmax = 3
local storedhuman = nil
local idleanim = Tool.Idle
local idleanimr15 = Tool.IdleR15
local loadedidle = nil
local shootanim = Tool.Shoot
local shootanimr15 = Tool.ShootR15
local loadedshoot = nil
local crouchanim = Tool.Crouch
local crouchanimr15 = Tool.CrouchR15
local loadedcrouch = nil
local meleeanim = Tool.MeleeA
local meleeanimr15 = Tool.MeleeAR15
local loadedmelee = nil
local zoomed = false
local equipped = false
AmmoDisplay = script:WaitForChild(âAmmoDisplayâ):Clone()
AmmoDisplayClone = nil
local Mouse = nil
local function AdjustAmmoDisplay()
local Frame = AmmoDisplayClone.Frame
local Ammo = Frame.Ammo
Ammo.AmmoCounter.CounterPart.Text = toolammo.Value
end
local function UpdateIcon()
if Mouse then
âMouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
âMouse.Icon = MOUSE_ICON
Mouse.Icon = toolammo.Value>0 and MOUSE_ICON or RELOADING_ICON
end
end
local function UpdateHitmarker()
hitmarkerframes=hitmarkerframesmax
if AmmoDisplayClone and AmmoDisplayClone:FindFirstChild(âCrosshairâ) and Mouse then
AmmoDisplayClone.Crosshair.Hitmarker:Play()
end
end
local function OnEquipped(mouse)
equipped=true
local Character = Tool.Parent
local Player = Players:GetPlayerFromCharacter(Character)
local PlayerGui = Player:FindFirstChild(âPlayerGuiâ)
if PlayerGui then
AmmoDisplayClone = AmmoDisplay:Clone()
AdjustAmmoDisplay()
AmmoDisplayClone.Parent = PlayerGui
end
local humanoid = Character:FindFirstChild(âHumanoidâ)
if humanoid then
storedhuman = humanoid
end
if loadedidle==nil then
if storedhuman.RigType==Enum.HumanoidRigType.R15 then
loadedidle = humanoid:LoadAnimation(idleanimr15)
else
loadedidle = humanoid:LoadAnimation(idleanim)
end
loadedidle.Priority = Enum.AnimationPriority.Movement
loadedidle.Looped = true
end
if loadedshoot==nil then
if storedhuman.RigType==Enum.HumanoidRigType.R15 then
loadedshoot = humanoid:LoadAnimation(shootanimr15)
else
loadedshoot = humanoid:LoadAnimation(shootanim)
end
loadedshoot.Priority = Enum.AnimationPriority.Action
end
if loadedcrouch==nil then
if storedhuman.RigType==Enum.HumanoidRigType.R15 then
loadedcrouch = humanoid:LoadAnimation(crouchanimr15)
else
loadedcrouch = humanoid:LoadAnimation(crouchanim)
end
loadedcrouch.Priority = Enum.AnimationPriority.Movement
loadedcrouch.Looped = true
end
if loadedmelee==nil then
if storedhuman.RigType==Enum.HumanoidRigType.R15 then
loadedmelee = humanoid:LoadAnimation(meleeanimr15)
else
loadedmelee = humanoid:LoadAnimation(meleeanim)
end
loadedmelee.Priority = Enum.AnimationPriority.Action
end
loadedidle:Play()
fanim(1)
Mouse = mouse
UserInputService.MouseIconEnabled=false
UpdateIcon()
end
local function OnChanged(property)
if property == âEnabledâ then
UpdateIcon()
end
end
function Unequipped()
equipped=false
AmmoDisplayClone:Destroy()
UserInputService.MouseIconEnabled=true
loadedidle:Stop()
loadedshoot:Stop()
loadedcrouch:Stop()
loadedmelee:Stop()
workspace.CurrentCamera.FieldOfView = 70
zoomed = false
fanim(3)
end
Tool.Equipped:connect(OnEquipped)
Tool.Changed:connect(OnChanged)
Tool.Unequipped:connect(Unequipped)
handle = Tool.Handle
mouse = game.Players.LocalPlayer:GetMouse()
local UserInputService = game:GetService(âUserInputServiceâ)
local pressed = UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)
colors = {45, 119, 21, 24, 23, 105, 104}
function fire(v)
firefunction:FireServer(v)
end
function reload()
reloadfunction:FireServer()
end
function fanim(v)
animatefunction:FireServer(v)
end
function crouch()
crouchfunction:FireServer()
end
function melee()
meleefunction:FireServer()
end
local function checkhumanoid()
local character = Tool.Parent;
local humanoid = character:FindFirstChild(âHumanoidâ)
if humanoid then
storedhuman = humanoid
return true
end
if humanoid == nil then
âprint(âHumanoid not foundâ)
return false
elseif humanoid.Health<=0 then
âprint(âu are ded not big surpriseâ)
return false
end
end
local function onInputBegan(input, gameProcessed)
if not checkhumanoid() then
return
end
âif input.UserInputType == Enum.UserInputType.MouseButton2 then
â delay(0, function()
â while UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) do
â wait()
â workspace.CurrentCamera.FieldOfView = 30
â end
â workspace.CurrentCamera.FieldOfView = 70
â end)
âend
if input.UserInputType == Enum.UserInputType.Keyboard then
if UserInputService:IsKeyDown(Enum.KeyCode.R) then
reload()
end
if UserInputService:IsKeyDown(Enum.KeyCode.C) then
crouch()
end
if UserInputService:IsKeyDown(Enum.KeyCode.E) then
if not zoomed then
zoomed = true
workspace.CurrentCamera.FieldOfView = 50
else
zoomed = false
workspace.CurrentCamera.FieldOfView = 70
end
end
if UserInputService:IsKeyDown(Enum.KeyCode.V) then
melee()
end
end
end
script.Parent:WaitForChild(âanimateâ).OnClientEvent:Connect(function(id)
if not checkhumanoid() then
return
end
if id==1 then
loadedidle:Stop()
loadedcrouch:Play()
end
if id==2 then
loadedidle:Play()
loadedcrouch:Stop()
end
end)
script.Parent:WaitForChild(âmeleeâ).OnClientEvent:Connect(function(id)
if not checkhumanoid() then
return
end
if id==1 then
loadedmelee:Play()
end
end)
script.Parent:WaitForChild(âreloadâ).OnClientEvent:Connect(function(id)
if not checkhumanoid() then
return
end
AdjustAmmoDisplay()
if id==1 then
if AmmoDisplayClone and AmmoDisplayClone:FindFirstChild(âCrosshairâ) then
if AmmoDisplayClone.Crosshair:FindFirstChild(âReloadingLabelâ) then
AmmoDisplayClone.Crosshair.ReloadingLabel.Visible = true
end
end
end
if id==2 then
if AmmoDisplayClone and AmmoDisplayClone:FindFirstChild(âCrosshairâ) then
if AmmoDisplayClone.Crosshair:FindFirstChild(âReloadingLabelâ) then
AmmoDisplayClone.Crosshair.ReloadingLabel.Visible = false
end
end
end
end)
script.Parent:WaitForChild(âfireâ).OnClientEvent:Connect(function(id)
if not checkhumanoid() then
return
end
if id==1 then
UpdateIcon()
AdjustAmmoDisplay()
end
end)
script.Parent:WaitForChild(âhitmarkerâ).OnClientEvent:Connect(function(id)
if id==1 then
UpdateHitmarker()
end
end)
Tool.Enabled = true
function onActivated()
if not Tool.Enabled then
return
end
pressed = UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)
while pressed and equipped do
pressed = UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)
if pressed then
Tool.Enabled = false
local character = Tool.Parent;
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
storedhuman = humanoid
end
if humanoid == nil then
--print("Humanoid not found")
return
elseif humanoid.Health<=0 then
--print("u are ded not big surprise")
return
end
local targetPos = humanoid.TargetPoint
local lookAt = (mouse.Hit.p - handle.Position).unit
--fanim(2)
fire(lookAt)
wait(.123)
Tool.Enabled = true
end
end
end
script.Parent.Activated:connect(onActivated)
UserInputService.InputBegan:Connect(onInputBegan)
while true do
wait()
if AmmoDisplayClone and AmmoDisplayClone:FindFirstChild(âCrosshairâ) and Mouse then
AmmoDisplayClone.Crosshair.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
local absoluteY = 650
AmmoDisplayClone.Crosshair:TweenSize(
UDim2.new(0, toolrecoil.Value/10000 * absoluteY * 2 + 23, 0, toolrecoil.Value/10000 * absoluteY * 2 + 23),
Enum.EasingDirection.Out,
Enum.EasingStyle.Linear,
0)
if AmmoDisplayClone.Crosshair:FindFirstChild(âTargetHitImageâ) then
if hitmarkerframes>0 then
AmmoDisplayClone.Crosshair.TargetHitImage.Visible=true
AmmoDisplayClone.Crosshair.TargetHitImage.ImageTransparency=1-(hitmarkerframes/hitmarkerframesmax)
hitmarkerframes-=1
else
AmmoDisplayClone.Crosshair.TargetHitImage.Visible=false
end
end
end
end
âwhile true do
â wait()
â pressed = UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)
â if pressed==true then
â if not Tool.Enabled then
â return
â end
â Tool.Enabled = false
â local character = Tool.Parent
â local humanoid
â if character then
â humanoid = character.Humanoid
â end
â if humanoid then
â local targetPos = humanoid.TargetPoint
â local lookAt = (mouse.Hit.p - character.Head.Position).unit
â fire(lookAt)
â wait(.5)
â end
â Tool.Enabled = true
â end
â print(pressed)
âend
this is the script of one of the offenders. it works fien in studio test but not in the actual game