Good morning, this is my first post and I am looking for a solution.
I use Google, this forum and change the code, but nothing works.
My game uses the Roblox Weapon Kit, although versatile, it has several bugs, I made some changes, since there are many parameters that if modified cause more bugs. My query is if there is any way to reactivate the use of the mouse to select items.
The main script fixes any attempt to change the camera type, shiftlock, or mouse cursor control.
I hope someone can help me, thanks in advance.
Please know that you should provide your code when asking for support related to scripting.
Also, I kind of didn’t understand your query.
Same thing with me here, I Don’t understand what you’re asking, and provide code when asking for support.
The Weapons Kit is from the Roblox Education site:
Weapons Kit
The issue is it forces camera lock to mouse movement and you lose your cursor. I have this on my To Do at some point but never got round to it. If anyone has a quick solution, then Yay.
Exacto…this is my problem.I got to send the players to main menu to do wathewer i want (shop, upgrades)
If you look in the WeaponsSystem
folder under the tool and go to the ClientWeaponsScript
, you will see a function, setupWeaponsSystem()
:
local function setupWeaponsSystem()
local WeaponsSystem = require(weaponsSystemFolder.WeaponsSystem)
if not WeaponsSystem.doingSetup and not WeaponsSystem.didSetup then
WeaponsSystem.setup()
WeaponsSystem.camera:setEnabled(false)
if player.Character then
onCharacterAdded(WeaponsSystem, player.Character)
end
player.CharacterAdded:Connect(function(character)
onCharacterAdded(WeaponsSystem, character)
end)
end
end
You may have noticed the line, WeaponsSystem.camera:setEnabled(false)
. That turns off the camera functionalities, and it can be accessed by requiring the WeaponsSystem
module evidently. It is useful to note that there is a function above setupWeaponsSystem()
, onCharacterAdded()
, which is used solely for toggling the camera system based on whether the character is holding a gun.
You can try your hand at creating a custom system for toggling the camera, maybe something like this:
-- in ClientWeaponsScript
local function onCharacterAdded(weaponsSystem, character)
character.ChildAdded:Connect(function(child)
if
child:IsA("Tool")
and CollectionService:HasTag(child, WEAPON_TAG)
and not menu.Open -- new pseudocode
then
weaponsSystem.camera:setEnabled(true)
end
end)
character.ChildRemoved:Connect(function(child)
if
child:IsA("Tool")
and CollectionService:HasTag(child, WEAPON_TAG)
then
weaponsSystem:setEnabled(false)
end
end)
end
-- menu pseudocode
-- these are modeled as events fired from your menu,
-- but you can just hard-code it in
menu.Opened:Connect(function()
weaponsSystem.camera:setEnabled(false)
weaponsSystem.gui:setEnabled(false) -- I have no idea how useful this is
end)
menu.Closed:Connect(function()
local weapon = character:FindFirstChildWhichIsA("Tool")
if weapon and CollectionService:HasTag(weapon, WEAPON_TAG) then
weaponsSystem.camera:setEnabled(true)
weaponsSystem.gui:setEnabled(true)
end
end)
The only problem I can think of with this method is that the WeaponsSystem
may still be active even with a gui up, so you might still be able to shoot your gun in the background. The WeaponsSystem
probably has a way to toggle itself as a whole through its setup
and shutdown
methods, but I am not entirely sure if there would be a more convenient method that just pauses input.
Please try this demo, you can set it back to mouse icon.
local userInputService = game:GetService("UserInputService")
local serverScript =game:GetService("ReplicatedStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WeaponsSystem = ReplicatedStorage:WaitForChild("WeaponsSystem")
local weaponModule = require(WeaponsSystem:WaitForChild("WeaponsSystem"))
local camera = workspace.Camera
local player = game:GetService("Players").LocalPlayer
--
userInputService.InputBegan:Connect(function(inputObject, gpe)
if not gpe then
if inputObject.UserInputType == Enum.UserInputType.Keyboard then
if inputObject.KeyCode == Enum.KeyCode.Q then
print("[z1]Can Shoulder camera for weapon")
weaponModule.camera:setEnabled(false)
weaponModule.camera.rotateCharacterWithCamera = false
camera.CameraSubject = player.Character
weaponModule.normalOffset = Vector3.new(0,0,0)
end
if inputObject.KeyCode == Enum.KeyCode.X then
print("[z1]Enable back to Shoulder camera")
weaponModule.camera:setEnabled(true)
weaponModule.camera.rotateCharacterWithCamera = true
end
end
end
end)