How Would I make a Advance magic system

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.

  1. 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

  2. What would be the best way to make a projectile move so there is little to no lag.

  3. Would tool or UIS be better for abilities.

  4. What is the best way to do hitboxes so they’re little exploiters.

3 Likes

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.

2 Likes

this is great
im going to try these things

1 Like

the projectile is great
but it doesn’t seem to move mid air like a benders will do I need to put mouse Position or something to make it move like that

you don’t have to get me a script for this on just nudge me but thanks for the script I wasn’t even aware there was a run service

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

2 Likes

Skip to 7:57 .

7:57

I don’t need a script but i would like to get nudged in the right direction .

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.

3 Likes

I did that how would I make the mouse not fling it.

I tried slowing dividing the mousePos it slowed down but it started yeeting the projectile everywhere.

You want to change the velocity. That’s what controls how fast it’s gonna go

1 Like

The speed is how I want it ,it’s just that it randomly zooms to somewhere i’m not even facing.

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)

end
end)
end
end)

I was thinking of using Mouse.Move() but I don’t know if it can get a vector3/CFrame.

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)

1 Like

I don’t understand how I can do that

what do you mean by

[you have to set the mouse cframe (as you did on `MagicMissle.CFrame = CFrame.new(StartPos, mouse.Hit.Position)]

I tried change the mouse cframe but its just giving errors sorry if that sounds dumb I’ve only be scripting for 2 months but I’m trying to learn a lot