-
I Want to make a shooting spell and I am making it a projectile.
-
The projectile does not work correctly, When I aim at a certain direction, It stop working, It either glitch or either the projectile does not exist.
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
local FastCast = require(script.FastCastRedux)
local Caster = FastCast.new()
Caster.LengthChanged:Connect(function(casterThatFired, lastPoint, rayDir, displacement, segmentVelocity, cosmeticBulletObject)
local Position = lastPoint + (rayDir * displacement)
cosmeticBulletObject.Position = Position
end)
Caster.RayHit:Connect(function(casterThatFired, result, segmentVelocity, cosmeticBulletObject)
end)
local Spells = {}
function Spells:Shoot(Player: Player, Tool: Tool, MousePosition: Vector3)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Handle: Part = Tool.Handle
local Direction = (MousePosition - Handle.Position).Unit
local DamagePart = game.ServerStorage["Damage part."]:Clone()
local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
RaycastParameters.FilterDescendantsInstances = {Character}
local FastCastBehavoiur = FastCast.newBehavior()
FastCastBehavoiur.MaxDistance = 150
FastCastBehavoiur.RaycastParams = RaycastParameters
FastCastBehavoiur.CosmeticBulletTemplate = game.ReplicatedStorage["Visual effects."].Projectile
FastCastBehavoiur.CosmeticBulletContainer = workspace
Caster:Fire(Tool["Build."].Part.Position, Direction, 100, FastCastBehavoiur)
end
return Spells
This script is a cut part of a much larger script.