I am trying to send a projectile but there are differences when using RayCast and Mouse.Hit.p.
the mouseaim function is being changed by the parent localscript. It’s value will depend on whatever the localscript uses. If the player uses RayCast, MouseAim is going to be a raycast and if it is a mouse it is going to return as a mouse. But when i use RayCast, the projectile is going upper than expected:
script.Parent.OnServerEvent:Connect(function(plr,direction,mouseaim,value)
local EZ = plr.Character:WaitForChild(“HumanoidRootPart”)
local fd = game.ReplicatedStorage.Fire.FireDisaster:Clone()
local ishitting = false
fd.Parent = game.Workspace
fd:PivotTo(EZ.CFrame + Vector3.new(0, 22, 0))
fd.HitIniatiator.Touched:Connect(function(hit)
if ishitting == false and hit.Parent.Name ~= "FireDisaster" and not hit.Parent:FindFirstChild("BLEH") then
fd.FXArea.CanTouch = true
fd.HitIniatiator.Anchored = true
fd.HitIniatiator.Transparency = 1
fd.MeshPart:Destroy()
local tween = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(4.5, Enum.EasingStyle.Linear)
fd.Main.Color = Color3.fromRGB(218, 133, 65)
tween:Create(fd.Main, tweenInfo, {Size = fd.Main.Size + Vector3.new(60, 60, 60)}):Play()
for _, v in fd.Main:GetChildren() do
if v:IsA("ParticleEmitter") then
v.Enabled = true
end
end
ishitting = true
local S = script.Explosion:Clone()
S.Parent = fd.Main
S:Play()
game:GetService("Debris"):AddItem(S, 6)
game:GetService("Debris"):AddItem(fd, 6.5)
wait(4.5)
tween:Create(fd.Main, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {Size = Vector3.new(0.1, 0.1, 0.1)}):Play()
for _, v in fd.Main:GetChildren() do
if v:IsA("ParticleEmitter") then
v.Enabled = false
end
end
wait(0.5)
fd.Main:Destroy()
fd.HitIniatiator:Destroy()
fd.FXArea:Destroy()
wait(0.5)
fd:Destroy()
end
end)
local BV = Instance.new("BodyVelocity")
BV.Parent = fd.HitIniatiator
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = CFrame.new(EZ.Position + Vector3.new(0, 22, 0), mouseaim).LookVector * 50