example: 2022-09-21 18-48-11 GIF by whereiuploaddevforum | Gfycat
any help apprieciated!
local script:
local uis = game:GetService("UserInputService")
local remote = game.ReplicatedStorage:WaitForChild("Ability")
local mousep = true
uis.InputBegan:Connect(function(k)
if k.KeyCode == Enum.KeyCode.E then
if mousep == true then
local c = game.Workspace.CurrentCamera
local mp = uis:GetMouseLocation()
remote:FireServer(true,c:ScreenPointToRay(mp.x,mp.y).Direction)
else
remote:FireServer(false)
end
end
end)
Server script:
local remote = game.ReplicatedStorage:WaitForChild("Ability")
local abilities = game.ReplicatedStorage:WaitForChild("Abilities")
local tweensv = game:GetService("TweenService")
local info = TweenInfo.new(10,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local goals = {
Orientation = Vector3.new(0,0,1000)
}
remote.OnServerEvent:Connect(function(plr,isMousePos,mousePos)
local char = game.Workspace:FindFirstChild(plr.Name)
if char then
local root = char:FindFirstChild("HumanoidRootPart")
local hum = char:FindFirstChild("Humanoid")
if root and hum then
local fireball = abilities.Fire.Fireball:Clone()
fireball.Anchored = false
fireball.Parent = workspace
local fireballtween = tweensv:Create(fireball,info,goals)
if mousePos then
fireball.CFrame = CFrame.lookAt(root.Position, mousePos)
else
fireball.CFrame = root.CFrame
end
fireball.Orientation = fireball.Orientation + Vector3.new(0,-180,0)
local bv = Instance.new("BodyVelocity",fireball)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local speed = 100
if isMousePos then
bv.Velocity= mousePos * speed
--bv.Velocity = fireball.CFrame.LookVector*speed
else
bv.Velocity= root.CFrame.lookVector * speed
end
fireballtween:Play()
game:GetService("Debris"):AddItem(fireball,10)
end
end
end)