Hello I am relatively new to luau can anyone nudge me in the right directions for making a system like that not asking for scripts just where to start researching.
I saw a really cool game call “A Bender’s Will”
they had a system for making the projectile move mid air on mouse movement how would some some achieve this IE: lerping ect
What would be the best way to make a projectile move so there is little to no lag.
Would tool or UIS be better for abilities.
What is the best way to do hitboxes so they’re little exploiters.
The simplest way is to a connect an event to RunService.RenderStepped (fires before every frame is rendered). Every frame, you’re gonna move the MagicMissle forward by 5 studs (the velocity). Because lag can cause frame drops, you’re gonna multiply the movement by DeltaTime * 60, which is the time between frames. Optimally, Deltatime will be 1/60 (cause 60fps) which is why we multiply by 60.
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MagicMissle = ReplicatedStorage.MagicMissle:Clone() --The magic thingy we are firing forward
local StartPos = Vector3.new(0,0,0)
local MaxDistanceTraveled = 3000
MagicMissle.Position = StartPos
MagicMissle.Parent = workspace --Parenting it to workspace so we can see it
local MissleVelocity = 5
local OnFrame --this is the variable that will hold our .Heartbeat connection
OnFrame = RunService.RenderStepped:Connect(function(DeltaTime)
MagicMissle.CFrame *= CFrame.new(0,0, MissleVelocity * DeltaTime * 60)
if (MagicMissle - StartPos).magnitude > 3000 then
--the missle went too far!
MagicMissle:Destroy()
end
end)
Use this code to get you started and add on as you need. If you want projectile drop I recommend you search up a module named FastCast on the devforum.
Answered above. This will cause minimal lag. Do NOT use a bodyvelocity or a while true do loop with a wait().
Tool is simpler, UIS is industry standard™
You could use something like RaycastHitbox (search up on devforum) which is accurate and not buggy, or you can use a .Touched event. Be warned that they ARE exploitable (exploiters can fire them from any where, even if the event is on the server since it’s replicatable), but you can use a distance check like I did on the missle to make sure that they’re close enough to touch the object.
Wdym move mid air? If you want it to ‘shoot’ like a gun towards your mouse cursor set the projectile cframe to cframe.new(startpos, mousepos) so it points to the mouse, then the runservice thingy to make it go forward
When the tool is activated, you will connect a .RenderStepped event which points the boulder to the mouse cursor position and move it forward by velocity every step.
local UIS = game:GetService(“UserInputService”)
local RunService = game:GetService(“RunService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RE = ReplicatedStorage.Missile
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local MaxDistanceTraveled = 30000
local mouse = game.Players.LocalPlayer:GetMouse()
local MissleVelocity = 0.1
UIS.InputEnded:Connect(function(input,typing)
if input.KeyCode == Enum.KeyCode.F and not typing then
local MagicMissle = ReplicatedStorage.MagicMissle:Clone()--The magic thingy we are firing forward
local StartPos = char:WaitForChild("RightHand").Position
MagicMissle.CFrame = CFrame.new(StartPos, mouse.Hit.Position)
MagicMissle.Parent = workspace --Parenting it to workspace so we can see it
local OnFrame --this is the variable that will hold our .Heartbeat connection
OnFrame = RunService.RenderStepped:Connect(function(DeltaTime)--runs every frame
MagicMissle.CFrame *= CFrame.new(0,0, -MissleVelocity * DeltaTime * 60) * CFrame.new(mouse.Hit.Position/1000)
if (MagicMissle.Position - StartPos).Magnitude > MaxDistanceTraveled then
--the missle went too far!
game.Debris:AddItem(MagicMissle, 1)
Your problem is that you have to set the mouse cframe (as you did on MagicMissle.CFrame = CFrame.new(StartPos, mouse.Hit.Position) inside the .RenderStepped connection (because your mouse hit is gonna change position every frame)