nvm i fixed the mouse problem, here are the fixed versions
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Debris = game:GetService("Debris")
local animations = script:WaitForChild("Animations")
local Fireball
local Weld
local hold
local throw
local strstring = "start"
local endstring = "end"
Event.OnServerEvent:Connect(function(player, str)
local chr = player.Character or player.CharacterAdded:Wait()
local hum = chr:WaitForChild("Humanoid")
local rootpart = chr:WaitForChild("HumanoidRootPart")
local holdinghand = chr:WaitForChild("Left Arm")
hold = hum.Animator:LoadAnimation(animations:WaitForChild("FireballHold"))
throw = hum.Animator:LoadAnimation(animations:WaitForChild("FireballThrow"))
if str == strstring and not hold.IsPlaying then
print("play")
hold:Play(0)
Fireball = game:GetService("ServerStorage"):WaitForChild("Fireball"):Clone()
Fireball.Parent = workspace
Fireball.CFrame = holdinghand.CFrame * CFrame.new(0,-1,1)
Fireball:SetNetworkOwner(nil)
Weld = Instance.new("WeldConstraint", Fireball)
Weld.Part0 = Fireball
Weld.Part1 = holdinghand
end
end)
Event.OnServerEvent:Connect(function(player, str, hit)
local mouse = player:GetMouse()
local chr = player.Character or player.CharacterAdded:Wait()
local hum = chr:WaitForChild("Humanoid")
local rootpart = chr:WaitForChild("HumanoidRootPart")
local holdinghand = chr:WaitForChild("Left Arm")
if str == endstring and hold.IsPlaying then
print("stop")
hold:Stop()
throw:Play()
throw:AdjustSpeed(2)
Weld:Destroy()
local BV = Instance.new("BodyVelocity", Fireball)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.P = 10000000
BV.Velocity = hit.LookVector * 100
Fireball.Touched:Connect(function(Touched)
if Touched:IsDescendantOf(chr) then return end
local h = Touched.Parent:WaitForChild("Humanoid")
if h then
local root = Touched.Parent:WaitForChild("HumanoidRootPart")
local y = Instance.new("BodyVelocity")
y.maxForce = Vector3.new(-10000, 0, 0)
y.Parent = root
y.velocity = root.CFrame.LookVector * 50
Debris:AddItem(y,.5)
--for _,v in pairs(Fireball:GetDescendants()) do
-- if v:IsA("PointLight") or v:IsA("Trail") then
-- v.Enabled = false
-- elseif v:IsA("ParticleEmitter") then
-- v:Destroy()
-- end
--end
if h then
h:TakeDamage(30)
--wait(0.5)
-- Touched.Parent:WaitForChild("Ragdoll").Value = true
--wait(4)
--Touched.Parent:WaitForChild("Ragdoll").Value = false
end
Fireball:Destroy()
throw:Stop()
else
warn("No humanoid available.")
return
end
end)
Debris:AddItem(Fireball,5)
end
end)
local p = game:GetService("Players").LocalPlayer
local mouse = p:GetMouse()
local r = game:GetService("ReplicatedStorage").RemoteEvent
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
r:FireServer("start")
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
r:FireServer("end", mouse.Hit)
end
end)
You just had to get the Mouse.hit in the LocalScript, then that transfers the position over to the ServerScript, inside of the Hit variable of the ServerScript, which you could use for the LookVector
I removed the wait(1)
inside of the TakeDamage event, because it was just instantly killing your player. Now the hits should be more efficient
also fixed something where i accidentally parented the fireball two times, whoopsies lol
fixed something with the serverscript