You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? A script where if you click you can damage yourself.
-
What is the issue? hats not working with the script. But I think it also does the same thing if its a model.
Example (Humanoid is not a valid member of Accessory "Workspace.irlkalei.Meshes/smugAccessory" - Client - LocalScript:20) I want it to damage them even if they have a hat to block it.
local RunService = game:GetService("RunService")
local cam = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local item = nil
local function MouseRayCast()
local mousepos = UIS:GetMouseLocation()
local mouseray = cam:ViewportPointToRay(mousepos.X, mousepos.Y)
local rcr = workspace:Raycast(mouseray.Origin, mouseray.Direction*1000)
return rcr
end
UIS.InputBegan:Connect(function(input, processed)
if processed then
return
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local result = MouseRayCast()
if result and result.Instance then
result.Instance.Parent.Humanoid.Health = result.Instance.Parent.Humanoid.Health - 25
end
end
end)
RunService.RenderStepped:Connect(function()
local result = MouseRayCast()
if result and result.Instance then
item = result.Instance
end
end)
- What solutions have you tried so far? Ai, rescripting the line.