local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local shootEvent = ReplicatedStorage.Events.ShootEvent
local shootSound = SoundService.ShootSound
local function onShootEvent(player, mousePosition: Vector3, shootCursorPosition: Vector3)
local direction = (mousePosition - shootCursorPosition)
local result = workspace:Raycast(shootCursorPosition, direction)
shootSound:Play()
if result then
print(result.Instance)
local humanoid = result.Instance.Parent:FindFirstChild("Humanoid"):: Humanoid
if humanoid then
humanoid:TakeDamage(10)
end
end
end
shootEvent.OnServerEvent:Connect(onShootEvent)
It should be (mousePosition - shootCursorPosition).Unit
.
Also, you should just raycast on the client and then send the results to the server for processing.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.