You dont make the viewmodel visible to the other players, you just tell the server to clone the gun model and weld it to the player’s character and probably play an animation
But how would the animation play on the server tho since the animation is made on the viewport not on the character?
You make a separate animation for the server, you can’t run viewmodel animations on character animations anyways.
I fixed it by welding the gun parts to the handle manually, not through a script
When I export the animation, it exports as a KeyFrameSequence, and it says in the output LoadAnimation requires an Animation object. How do I get the animation?
nvm i fixed it
What did you do to get this working?
Did you ever fix this? I have having the same issue.
it’s because of the gun barrel and the end position, i recommend you raycasting from the head to the barrel to see if it’s obstructed, if it is make it so you shoot from the head instead.
Here’s my scripts:
MainModule:
LocalHandler:
The scripts aren’t working for some reason and I don’t know if it’s because I’m pretty inexperienced with scripting (I only know the basics) or I mixed up the scripts. What did I do wrong here?
What’s a LocalHandler? Do I have to create a LocalScript and name it LocalHandler?
When I do this, it comes back with an error:
I put the last 3 lines of code from that image inside my LocalScript named “LocalHandler” and nothing happens. And it also says this:
Here’s my explorer:
What did I do wrong and what are the LocalScript and ModuleScript supposed to look like? I can’t find any sources anywhere even the discord server and have bene trying to get help for the past day. I’ve been stuck for a while now.
I recommend you to learn these first
Are you able to help me with what I asked for? I’m gonna be coming back to this tutorial 3 years from now if I really learn atleast 3 of those things. All I’m asking is to follow your tutorial so please help me.
I’m pretty sure a beginner’s tutorial shouldn’t take 2-3 years to learn/master, and I do have some knowledge on all of them. It really isn’t much to ask for and I’ve been waiting for 3 days now so please could I get some help, I’m being as kind and respectful as I can.
If this is a beginner tutorial you’re supposed to help the beginner understand what he or she is doing wrong, and assist them with it so that they can have a better understanding at scripting and be able to build off of this tutorial.
It doesn’t take 3 years to learn the basics of modules and CFrames. An FPS framework is hard to make, I expect people who follow this tutorial to have at least have experience on how a script works and if you do have some knowledge to follow this tutorial then you should be smoothly following this tutorial like other people are doing. I also have personal life that I need to focus on. I don’t answer answer questions immediately and I also don’t answer repetitive questions.
As I said I expect people who follows this tutorial to have a good general knowledge of lua. Not absolute beginner to the point they don’t know how modules work or how welding works. This tutorial just aims to teach you the idea of an FPS framework not a polished one as I said in the beginning of the post.
Now moving forward to your question.
In order to make a module, you must first insert a ModuleScript. In the code it should already have a default. You just need to add the line I posted in the tutorial
local module = {}
function module.update(viewmodel, dt)
viewmodel.HumanoidRootPart.CFrame = workspace.Camera.CFrame
end
return module
Now I don’t know why I need to explain this if you said you have experience with module scripts. Even the error tells you why
I think i do something wrong so much my bullet is spawn on my mouse
module
local module = {}
function module.update(viewmodel,dt)
viewmodel.HumanoidRootPart.CFrame = game:GetService("Workspace").Camera.CFrame
end
function module.weldgun(gun)
local main = gun.GunComponents.Handle
for i,v in ipairs(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 gunhanlde = gun.GunComponents.Handle
local HRPmotor = viewmodel:WaitForChild("HumanoidRootPart").Handle
gun.Parent = viewmodel
HRPmotor.Part1 = gunhanlde
local Hold = viewmodel.AnimationController:LoadAnimation(hold)
Hold:Play()
end
function module.cast(gun,EP,Velo)
local gunbarrel = gun.GunComponents.Barrel
local Bullet = Instance.new("Part")
Bullet.Size = Vector3.new(10, 10, 5)
Bullet.Anchored = true
Bullet.CanCollide = false
Bullet.Color = Color3.new(219, 239, 0)
Bullet.Material = Enum.Material.Neon
Bullet.Parent = game.Workspace
Bullet.CFrame = CFrame.new(gunbarrel.Position, EP)
local loop
print(Bullet.Position)
loop = game:GetService("RunService").RenderStepped:Connect(function(dt)
Bullet.CFrame *= CFrame.new(0, 0, -Velo * (dt * 60))
if (Bullet.Position - gunbarrel.Position).Magnitude > 5000 then
loop:Disconnect()
Bullet:Destroy()
end
end)
end
return module
local
local gun = game:GetService("ReplicatedStorage").Model:WaitForChild("Groza")
local viewmodel = game:GetService("ReplicatedStorage").Model:WaitForChild("Viewmodel")
local mainmodule = require(game:GetService("ReplicatedStorage").GunWork)
local AnimationF = game:GetService("ReplicatedStorage"):WaitForChild("Animation")
viewmodel.Parent = game:GetService("Workspace").Camera
mainmodule.weldgun(gun)
game:GetService("RunService").RenderStepped:Connect(function(dt)
mainmodule.update(viewmodel,dt)
end)
mainmodule.equip(viewmodel, gun, AnimationF.Hold)
local holdmouse = false
local canfire = true
local Delays = 0.1
game:GetService("RunService").Heartbeat:Connect(function(dt)
if holdmouse then
if canfire then
canfire = false
mainmodule.cast(gun, game.Players.LocalPlayer:GetMouse().Hit.Position, 60)
wait(Delays)
canfire = true
end
end
end)
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
holdmouse = true
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
holdmouse = false
end
end)
Anyone have an animation link or know how to create the hold animation because whenever I create it, it looks messed up.
Is there anyway to lower the movement bobbing sensitivity?
Is the gun/accessory rotated in a different direction? If so…
-
Rotate the Handle object inside Gun Components til your salified
-
Try to use a decal or surface Gui to find the front of the handle and adjust from there
If you need some held animated There are plenty tutorials on the internet, I suggest using Moon animator
Do you mean the bobbing scale? Or the bobbing literal sensitivity as in you want the player to travel at a greater speed to activate the bobble effect?
I’ll give you both anyways
in the bobbing function, add another parameter called scale and you can replace the 0.5 with it
return sin(tick() * mult) * scale
If you mean in the second one then in the bobbing shoving instead of directly applying the velocity magnitude, you first want to check if it reaches the target one then shove it, a second option is to subtract and clamp it
velocity = clamp(velocity - 2, 0, round(velocity)
I already fixed my issue by myself