Idk jf
It is my mouse that does not work but it does work for other games
I’m online now The code i am using is
local module = {}
function module.update(viewmodel, dt)
viewmodel.HumanoidRootPart.CFrame = game.Workspace.Camera.CFrame
end
function module.weldgun(gun)
local Main = gun.GunComponents.Handle
for i, v in pairs(gun:GetDescendants()) do
if v:IsA("BasePart") and v ~= Main then
local NewMotor = Instance.new("Motor6D")
NewMotor.Name = v.Name
NewMotor.Part0 = Main
NewMotor.Part1 = v
NewMotor.C0 = NewMotor.Part0.CFrame:Inverse() * NewMotor.Part1.CFrame
NewMotor.Parent = Main
end
end
end
function module.equip(viewmodel, gun, hold)
local GunHandle = gun.GunComponents.Handle
local HRP_Motor6d = viewmodel:WaitForChild("HumanoidRootPart").Handle
gun.Parent = viewmodel
HRP_Motor6d.Part1 = GunHandle
HRP_Motor6d.Part0 = viewmodel.HumanoidRootPart
local Hold = viewmodel.AnimationController:LoadAnimation(hold)
Hold:Play()
end
function module.cast(gun, endposition, velocity)
local GunBarrel = gun.GunComponents.Barrel
local Bullet = Instance.new("Part")
Bullet.Size = Vector3.new(1, 1, 5)
Bullet.Anchored = true
Bullet.CanCollide = false
Bullet.Color = Color3.new(0.999084, 0.947265, 0.604257)
Bullet.Material = Enum.Material.Neon
Bullet.Parent = game.Workspace
Bullet.CFrame = CFrame.new(GunBarrel.Position, endposition)
Loop = game:GetService("RunService").RenderStepped:Connect(function(dt)
Bullet.CFrame *= CFrame.new(0, 0, -velocity * dt)
if (Bullet.Position - GunBarrel.Position).magnitude > 5000 then
Bullet:Destroy()
Loop:Disconnect()
end
end)
end
return module
The local Handler
local GunModel = game.ReplicatedStorage:WaitForChild("Groza")
local ViewModel = game.ReplicatedStorage:WaitForChild("Viewmodel")
local AnimationsFolder = game.ReplicatedStorage:WaitForChild("Groza_Animations")
--main module thing
local MainModule = require(game.ReplicatedStorage.MainModule)
ViewModel.Parent = game.Workspace.Camera
game:GetService("RunService").RenderStepped:Connect(function(dt)
MainModule.update(ViewModel, dt)
end)
MainModule.weldgun(GunModel)
MainModule.equip(ViewModel, GunModel, AnimationsFolder.Hold)
local IsPlayerHoldingMouse
local CanFire = true
local Delay = 0.1
game:GetService("RunService").Heartbeat:Connect(function(dt)
if IsPlayerHoldingMouse then
if CanFire then
CanFire = false
MainModule.cast(GunModel, game.Players.LocalPlayer:GetMouse().Hit.Position, 60)
wait(Delay)
CanFire = true
end
end
end)
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
IsPlayerHoldingMouse = true
end
end)
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
IsPlayerHoldingMouse = false
end
end)
Edit: Never mind i understood my mistake i put Input began when it was suppose to be inputEnded
Both of these events are InputBegan. Make the one at the bottom InputEnded
I use your code and models, follow your tutorial from a to z. But the arm DIDN’T show up and so did the gun. Can you send me an uncopylocked place that include everything you show?
Hey, I need help, I keep getting this error:Handle is not a valid member of MeshPart “Workspace.Camera.Viewmodel.HumanoidRootPart”
Here are my scripts:
Local Handler
repeat wait() until game:IsLoaded()
local GunModel = game.ReplicatedStorage:WaitForChild("Groza") -- your gun
local ViewModel = game.ReplicatedStorage:WaitForChild("Viewmodel") -- the viewmodel!!
-- our main module
local MainModule = require(game.ReplicatedStorage.MainModule)
ViewModel.Parent = game.Workspace.Camera
GunModel.Parent = ViewModel
MainModule.weldgun(GunModel)
game:GetService("RunService").RenderStepped:Connect(function(dt)
MainModule.update(ViewModel, dt)
end)
MainModule.equip(ViewModel, GunModel)
MainModule:
local module = {}
function module.update(viewmodel, dt)
viewmodel.HumanoidRootPart.CFrame = game.Workspace.Camera.CFrame
end
function module.weldgun(gun)
local Main = gun.GunComponents.Handle
print("1")
local d
for i, v in ipairs(gun:GetDescendants()) do
print("2")
if v:IsA("BasePart") and v ~= Main then
print("3")
local newMotor = Instance.new("Motor6D")
newMotor.Name = v.Name
newMotor.Part0 = Main
newMotor.Part1 = v
newMotor.C0 = newMotor.Part0.CFrame:Inverse() * newMotor.Part1.CFrame
newMotor.Parent = Main
end
end
print("4")
end
function module.equip(viewmodel, gun)
local GunHandle = gun.GunComponents.Handle
local HRP_Motor6D = viewmodel:WaitForChild("HumanoidRootPart").Handle
gun.Parent = viewmodel
HRP_Motor6D.Part1 = GunHandle
end
return module
One question, if I wanted to have multiple different weapons, would I just put the handler in the gun and move it to the player when the gun is needed?
Make sure the Motor6D are in place correctly
I wouldn’t recommend it, instead just have 1 handler or module if you want to. and switch between guns there (remove the handle weld p1 and reattaching to the new gun (and possible change the settings like damage as well))
I think better to use:
game:GetService("Debris"):AddItem(Bullet,LifeTime)
Not necessarily, if your bullet travels slowly it can be problem. So it’s better to check for distance.
Unsure what I am doing wrong here but the gun doesnt appear in head (up to stage where Ive got equip/weld/update all setup) and im using same gun model and viewmodel. Unsure if it’ll affect animating in the future
local Framework = {}
function Framework.Update(viewModel, deltaTime)
viewModel.HumanoidRootPart.CFrame = workspace.CurrentCamera.CFrame
end
function Framework.WeldGun(gun)
local Handle = gun.Components.Handle
for i, v in ipairs(gun:GetDescendants()) do
if v:IsA("BasePart") and v ~= Handle then
local NewMotor = Instance.new("Motor6D")
NewMotor.Name = v.Name
NewMotor.Part0 = Handle
NewMotor.Part1 = v
NewMotor.C0 = NewMotor.Part0.CFrame:Inverse() * NewMotor.Part1.CFrame
NewMotor.Parent = Handle
end
end
end
function Framework.Equip(viewModel, gun)
local Handle = gun.Components.Handle
local HumanoidRootPartMotor = viewModel:WaitForChild("HumanoidRootPart").Handle
gun.Parent = viewModel
HumanoidRootPartMotor.Part1 = Handle
end
return Framework
local GunModel = game.ReplicatedStorage:WaitForChild("Gun"):Clone()
local ViewModel = game.ReplicatedStorage:WaitForChild("ViewModel"):Clone()
local Framework = require(game.ReplicatedStorage.Framework)
ViewModel.Parent = workspace.CurrentCamera
Framework.WeldGun(GunModel)
game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
Framework.Update(ViewModel, deltaTime)
end)
Framework.Equip(ViewModel, GunModel)
I’m pretty sure there’s something wrong with the welding or the gun model, or maybe even the viewmodel itself, but there will technically be no problem with animating it (other than its weird to animate the gun like that and a possibility of it randomly fixing itself in the future and breaking the animation).
Hi, are you able to make the animation free or give file to re upload?
Woah! Nice tutorial! I’ll definitely use this in the future.
Also I have a smol question, what font do you use?
mate just gotta say that this is one of the easiest to understand tutorial about fps frameworks cause some involves tons of math which they don’t explain and I don’t understand lol but yours it’s pretty self explanatory definitely helps me thanks
Why isn’t my hold animation working?
So when I test, the gun is parented to my viewmodel, but it is invisible and when I move, the gun doesnt move someone pls help
How would I make the framework show to the other clients? as an example, you can see other players holding their guns on Phantom Forces.
Simply send a signal to the server to display the server side model of the gun