Question: - - Replace with the name of your projectile model or part local projectileName = Blast - Wizard local tool = script.Parent.Parent - - Go
Replace with the name of your projectile model or part
local projectileName "BlastWizard"
local tool script.Parent.Parent Go up two levels to reach the Handle of the StaffWizard tool
Configurable parameters
local damageAmount Adjust the damage as needed
Preload the projectile model from ReplicatedStorage
local replicatedStorage game:GetServiceReplicatedStorage
local projectile replicatedStorage:WaitForChildprojectileName
local function shootProjectile
local player game.Players.LocalPlayer
local mouse player:GetMouse
local character player.Character or player.CharacterAdded:Wait
local humanoid character:WaitForChildHumanoid
local origin humanoid.Parent:WaitForChildHumanoidRootPartPosition
local direction mouseHit.p originunit
local newProjectile projectile:Clone
newProjectile.Parent game.Workspace
newProjectile.Position origin
Attach BodyPosition to update the position of the projectile
local bodyPosition Instance.newBodyPosition
bodyPosition.Position origin direction Adjust the distance as needed
bodyPosition.MaxForce Vectornewmathhuge, math.huge, math.huge
bodyPosition.Parent newProjectile
local hasDealtDamage false Flag to ensure damage is applied only once
local function onTouchedhit
if hasDealtDamage then
return
end
local hitHumanoid hit.Parent:FindFirstChildOfClassHumanoid
if hitHumanoid and hit.Parent ~ humanoid.Parent then
Deal damage or perform other actions as needed
hitHumanoid:TakeDamagedamageAmount
hasDealtDamage true Set the flag to true to prevent further damage
newProjectile:Destroy
elseif hit.Parent:IsATerrain then
Handle terrain collision if needed
newProjectile:Destroy
end
end
newProjectile.Touched:ConnectonTouched
Remove the projectile after seconds adjust as needed
wait
newProjectile:Destroy
end
tool.Activated:ConnectshootProjectile
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
