local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local camera = workspace.CurrentCamera
local Player = Players.LocalPlayer
local cameraOffset = Vector3.new(2,2,8)
local glock = script.Parent
local mouse = Player:GetMouse()
local cooldown = false
glock.Activated:Connect(function()
print("activated")
if cooldown then return end
cooldown = true
print("FIRE!!!")
script.Parent.RemoteEvent:FireServer(mouse.Hit.p)
wait(.3)
cooldown = false
end)
Player.CharacterAdded:connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
local rootPart = char:WaitForChild("HumanoidRootPart")
local cameraAngleX = 0
local cameraAngleY = 0
humanoid.AutoRotate = false
local function playerInput(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Change then
cameraAngleX -= inputObject.Delta.X
cameraAngleY = math.clamp(cameraAngleY - inputObject.Delta.Y * 0.4, -75, 75)
end
end
ContextActionService:BindAction("PlayerInput",playerInput,false,Enum.UserInputType.MouseMovement, Enum.UserInputType.Touch)
RunService:BindToRenderStep("CameraUpdate", Enum.RenderPriority.Camera.Value, function()
if script.Parent.Parent == char then
local startCFrame = CFrame.new(rootPart.CFrame.Position)*CFrame.Angles(0,math.rad(cameraAngleX),0) * CFrame.Angles(math.rad(cameraAngleY),0,0)
local cameraCFrame = startCFrame:PointToWorldSpace(cameraOffset)
local cameraFocus = startCFrame:PointToWorldSpace(Vector3.new(cameraAngleX,cameraOffset.Y, -100000))
camera.CFrame = CFrame.lookAt(cameraCFrame,cameraFocus)
local lookingCFrame = CFrame.lookAt(rootPart.Position, camera.CFrame:PointToWorldSpace(Vector3.new(0,0,-100000)))
rootPart.CFrame = CFrame.fromMatrix(rootPart.Position,lookingCFrame.XVector,rootPart.CFrame.YVector)
end
end)
end)
local function focusControl(actionName, inputState, inputObject)
if script.Parent.Parent:FindFirstChild("Humanoid") then
if inputState == Enum.UserInputState.Begin then
camera.CameraType = Enum.CameraType.Scriptable
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
--UserInputService.MouseIconEnabled = false
mouse.Icon = "rbxassetid://8230755404"
end
else
camera.CameraType = Enum.CameraType.Custom
mouse.Icon = [[]]
Player.Character.Humanoid.AutoRotate = true
end
end-- string name function add touch button inputTypes
glock.Equipped:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
--UserInputService.MouseIconEnabled = false
mouse.Icon = "rbxassetid://8230755404"
end)
glock.Unequipped:Connect(function()
camera.CameraType = Enum.CameraType.Custom
mouse.Icon = [[]]
end)
ContextActionService:BindAction("FocusControl", focusControl, false, Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch, Enum.UserInputType.Focus)
This is where the Tool.Activated connect is. near the end. So, I have handle, a gun, but Tool.Activated doesnt work. It doesnt print anything. Ive tried removing requires handle, and manual activation vice versa but nothing seems to work. If you have any questions lmk
I’ve also tried putting it in a serverscript and ina different localscript but nothing works.
the tool ^
And I also have a punch tool with it. When both the punch and gun are in the backpack, the punch doesnt work, but when i take the gun out of starterpack the punch works fine. I dont know what its doing.