Event.OnServerEvent:Connect(function(PlayerSent, Action, ...)
if PlayerSent == Player then
if Action == 'PlaySound' and Lib.RemoteFloodCheck(Player, 'Write', Event, Action, 20) then
PlaySound(...)
elseif Action == 'Fire' and Lib.RemoteFloodCheck(Player, 'Write', Event, Action, 10) then
Shoot(...)
end
end
end)
Client
Tool.Equipped:Connect(function(Mouse)
Equipped = true
Lib.ToolAttach('Attach', BodyAttach, Character.HumanoidRootPart)
Animations['Hold']:Play()
table.insert(Connections, Mouse.Button1Down:Connect(function()
MouseUp = false
Animations['Hold']:Stop()
Animations['Reload']:Play()
Event:FireServer('PlaySound', 'Reload', true)
Animations['Reload'].Stopped:Wait()
if Equipped and not MouseUp then
Animations['Draw']:Play()
Event:FireServer('PlaySound', 'Draw', true)
Animations['Draw'].Stopped:Wait()
if Equipped and not MouseUp then
Animations['Aim']:Play()
ReadyToFire = true
end
end
end))
table.insert(Connections, Mouse.Button1Up:Connect(function()
MouseUp = true
Animations['Reload']:Stop()
Animations['Draw']:Stop()
Animations['Aim']:Stop()
Event:FireServer('PlaySound', 'Reload', false)
Event:FireServer('PlaySound', 'Draw', false)
if ReadyToFire then
ReadyToFire = false
Tool.Arrow.Transparency = 1
Animations['Release']:Play()
Event:FireServer('PlaySound', 'Shoot', true)
Animations['Release'].Stopped:Wait()
if Equipped then
Tool.Arrow.Transparency = 0
Event:FireServer('Fire', Mouse.Hit.p) -- <-- Here's what you're looking for
end
end
Animations['Hold']:Play()
end))
end)
local character = game.Players.LocalPlayer.Character
function raycast(origin,endpos,distance)
local ray = Ray.new(origin,(origin-endpos).Unit*Distance)
local hit,pos,norm = workspace:FindPartOnRay(ray,character)
if hit then
print(hit.Name)
else
print('no hit')
end
end
Hm alright ill try using Raycast function then well
local Head = game.Players.LocalPlayer.Head
local Params = RaycastParams.new()
workspace:Raycast(Head.Position,(Head.Position - MouseHit).Unit*1000,Params)
if it doesnt work idk im new to that function aswell LOL
100% consistency now- but why did that work? Also, what about when I shoot in the sky? I don’t know how to fix that, it doesn’t fire if you shoot into the sky
Ray.new is not deprecated. The new WorldRoot::Raycast API does not use Ray, but there may be other APIs in the future which do, and the type still gets returned from ScreenPointToRay.