You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want tkeep the fps up while shooting a lot -
What is the issue? Include screenshots / videos if possible!
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Not really I have completely no idea how or where to start
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I am using fast cast for my framework
Client
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local fastcast = require(game.ReplicatedStorage.OtherModules.FastCastRedux)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local remote = game.ReplicatedStorage.Remotes.Gun
local mouse = plr:GetMouse()
local camera = game.Workspace.CurrentCamera
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
local isAiming = false
local aimCF = CFrame.new()
local shooting = false
local shootingDebounce = false
local framework = {
inventory = {
"M4A1";
};
module = nil;
viewModel = nil;
currentSlot = 1;
caster = nil;
}
function loadSlot(item)
local viewModelFolder = game.ReplicatedStorage.ViewModels
local moduleFolder = game.ReplicatedStorage.Modules
if moduleFolder:FindFirstChild(item) then
framework.module = require(moduleFolder:FindFirstChild(item))
if viewModelFolder:FindFirstChild(item) then
framework.viewModel = viewModelFolder:FindFirstChild(item):Clone()
framework.viewModel.Parent = camera
framework.caster = fastcast.new()
end
end
end
RunService.RenderStepped:Connect(function()
for i,v in ipairs(camera:GetChildren()) do
if v:IsA("Model") then
v:SetPrimaryPartCFrame(camera.CFrame * aimCF)
end
end
if isAiming and framework.viewModel ~= nil then
local offset = framework.viewModel.AimPart.CFrame:ToObjectSpace(framework.viewModel.PrimaryPart.CFrame)
aimCF = aimCF:lerp(offset,framework.module.aimSmooth)
elseif not isAiming and framework.viewModel ~= nil then
local offset = CFrame.new()
aimCF = aimCF:lerp(offset,framework.module.aimSmooth)
end
if shooting then
if shootingDebounce == false then
shootingDebounce = true
mouse.TargetFilter = framework.viewModel
params.FilterDescendantsInstances = {framework.viewModel,char}
local origin = framework.viewModel:FindFirstChild("FireOrigin").Attachment.WorldPosition
local dir = (mouse.Hit.p - origin).Unit
local velocity = framework.module.velocity
local behaviour = framework.caster.newBehavior()
behaviour.Acceleration = Vector3.new(0,-10,0)
behaviour.CosmeticBulletTemplate = game.ReplicatedStorage.Bullet
behaviour.CosmeticBulletContainer = workspace.Bullets
behaviour.MaxDistance = 2500
framework.caster.LengthChanged:Connect(function(cast,lastpoint,dir,length,velocity,bullet)
local blength = bullet.Size.Z/2
local offset = CFrame.new(0,0,-(length-blength))
bullet.CFrame = CFrame.lookAt(lastpoint,lastpoint+dir):ToWorldSpace(offset)
end)
framework.caster:Fire(origin,dir,velocity,behaviour)
framework.caster.RayHit:Connect(function(cast,result,velocity,bullet)
print("A")
remote:FireServer(result.Instance,result.Position,bullet)
Debris:AddItem(bullet,0)
wait(.1)
end)
wait(framework.module.fireRate)
shootingDebounce = false
end
end
end)
loadSlot(framework.inventory[1])
UIS.InputBegan:Connect(function(input,isTyping)
if not isTyping then
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isAiming = true
end
end
end)
UIS.InputEnded:Connect(function(input,isTyping)
if not isTyping then
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isAiming = false
end
end
end)
mouse.Button1Down:Connect(function()
if framework.viewModel ~= nil then
if framework.module.firemode == "Semi" then
print("Semi")
elseif framework.module.firemode == "Burst" then
print("Burst")
elseif framework.module.firemode == "Auto" then
shooting = true
end
end
end)
mouse.Button1Up:Connect(function()
if framework.viewModel ~= nil then
if framework.module.firemode == "Auto" then
shooting = false
end
end
end)
Server
local remote = game.ReplicatedStorage.Remotes.Gun
local debounce = false
remote.OnServerEvent:Connect(function(plr,hit,pos,bullet)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
if hit.Parent.Name ~= plr.DisplayName then
if debounce == false then
debounce = true
if hit.Name == "Head" then
print("Head")
hit.Parent.Humanoid:TakeDamage(20)
else
print("Body")
hit.Parent.Humanoid:TakeDamage(10)
end
wait()
debounce = false
end
end
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.