while wait() do
if game:IsLoaded()==true then
break
end
end
local Tool=[Link]
local Player=[Link]
local Mouse=Player:GetMouse()
local c=[Link]
local currentIcon="rbxasset://textures\\[Link]"
function Test(var,bool1,bool2)
if var==bool1 then
currentIcon="rbxasset://textures\\[Link]"
elseif var==bool2 then
currentIcon="rbxasset://textures\\[Link]"
end
end
Tool:GetPropertyChangedSignal("Enabled"):connect(function()
Test([Link],true,false)
c=[Link]
if not c then return end
local t=c:FindFirstChildWhichIsA("Tool")
if not t then return end
if t~=Tool then return end
[Link]=currentIcon
end)
[Link]:connect(function()
[Link]:FireServer([Link].p)
end)
if not c then
c=[Link]:Wait()
end
local head
local humanoid
while wait() do
head=c:FindFirstChild("Head")
humanoid=c:FindFirstChildWhichIsA("Humanoid")
if head and humanoid then
break
end
end
local iNew=[Link]
local cf=[Link]
local v3=[Link]
local terrain=[Link]
local grav=[Link]
local cam=[Link]
local r=game:GetService("RunService")
local attach0=iNew("Attachment")
[Link]=terrain
local attach1=iNew("Attachment")
[Link]=terrain
local beam=iNew("Beam")
[Link]=terrain
beam.Attachment0=attach0
beam.Attachment1=attach1
beam.Width0=2
beam.Width1=2
[Link]=50
[Link]=0.25
[Link]=0.25
[Link]="rbxassetid://2724621315"
[Link]=[Link](0.5)
[Link]=[Link]([Link](1,1,1))
--[Link]=true
local t=1
local function beamProjectile(g, v0, x0, t1) -- all credit to EgoMoose
-- calculate the bezier points
local c = 0.5*0.5*0.5
local p3 = 0.5*g*t1*t1 + v0*t1 + x0
local p2 = p3 - (g*t1*t1 + v0*t1)/3
local p1 = (c*g*t1*t1 + 0.5*v0*t1 + x0 - c*(x0+p3))/(3*c) - p2;
-- the curve sizes
local curve0 = (p1 - x0).magnitude;
local curve1 = (p2 - p3).magnitude;
-- build the world CFrames for the attachments
local b = (x0 - p3).unit;
local r1 = (p1 - x0).unit;
local u1 = r1:Cross(b).unit;
local r2 = (p2 - p3).unit;
local u2 = r2:Cross(b).unit;
b = u1:Cross(r1).unit;
local cf1=cf(
x0.x, x0.y, x0.z,
r1.x, u1.x, b.x,
r1.y, u1.y, b.y,
r1.z, u1.z, b.z
)
local cf2=cf(
p3.x, p3.y, p3.z,
r2.x, u2.x, b.x,
r2.y, u2.y, b.y,
r2.z, u2.z, b.z
)
return curve0, -curve1, cf1, cf2;
end
local function getTrajectory()
if not c then return end
local tool=c:FindFirstChildWhichIsA("Tool")
if (not tool) or [Link]~=c then return end -- ensure the player is
holding the tool
if [Link]==nil or [Link]==nil or [Link]==nil then return
end -- check if theyve been destroyed
if _G.ShowTrajectory==true then
[Link]=true
else
[Link]=false
return
end -- I know this is all very taxing, but otherwise I couldn't get it ALWAYS
working at the correct time
local targetPos=[Link].p
local lookAt=(targetPos - [Link]).unit
local spawnPos=[Link]
spawnPos=spawnPos+(lookAt*5)
local g = v3(0, -grav, 0)
local x0 = spawnPos --* v3(0, 2, -2)
--local v0 = ([Link].p - x0 - 0.5*g*t*t)/t
local v0 = --[[(]](lookAt*200) -- - 0.5*g*t*t)/t
local curve0, curve1, cf1, cf2 = beamProjectile(g, v0, x0, t)
beam.CurveSize0 = curve0
beam.CurveSize1 = curve1
-- convert world space CFrames to be relative to the attachment parent
[Link] = ([Link]:inverse() * cf1)-v3(0,0.4,0)
[Link] = ([Link]:inverse() * cf2)-v3(0,0.4,0)
end
[Link]:connect(function()
[Link]=currentIcon
r:BindToRenderStep("Trajectory",300,getTrajectory)
end)
[Link]:connect(function()
[Link]=""
pcall(function() r:UnbindFromRenderStep("Trajectory") end)
for i,v in pairs([Link]:GetChildren()) do
if v:IsA("Beam") then
[Link]=false
end
end
end)
[Link]:Connect(function()
for i,v in pairs([Link]:GetChildren()) do
if v:IsA("Beam") or v:IsA("Attachment") then
v:Destroy()
end
end
end)