- What do you want to achieve? Keep it simple and clear!
so i make it so that when you click it raycast but the raycast didnt
work and idk why and there are no errors too.
heres the code:
LocalScript
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local direction = HumanoidRootPart.CFrame.LookVector * 6
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
local rayParam = RaycastParams.new()
rayParam.FilterType = Enum.RaycastFilterType.Exclude
rayParam.FilterDescendantsInstances = {char}
local rayResult = workspace:Raycast(HumanoidRootPart.Position, direction, rayParam)
if rayResult == nil then return end
local otherchar = rayResult.Instance.Parent
local player = game.Players:GetPlayerFromCharacter(otherchar)
if player == nil then return end
attackEvent:FireServer(otherchar)
end
end)
ServerScript
local RS = game:GetService("ReplicatedStorage")
local attackEvent = RS:WaitForChild("AttackEvent")
attackEvent.OnServerEvent:Connect(function(plr, char)
char.Humanoid:TakeDamage(100)
end)