I am using a local script in a tool to determine the location of my mouse, then create a copy of a part in replicated storage.
When I test this and put make NewLN go to mouse position tit does nothing to the dummy humanoid when touching, however when i touch the dummy with my player and do it somehow it worked. I want it to make damage on its own.
here is my script:
tool = script.Parent
local ip = game:GetService("Players").LocalPlayer
local ui = game:GetService("UserInputService")
local db = false
local cd = 1
local EQ = false
local dmg = 10
local RS = game:GetService("ReplicatedStorage")
local LN = RS:WaitForChild("Lightning")
local player = game:GetService("Players").LocalPlayer
local desired desiredPosition = nil
tool.Equipped:Connect(function()
EQ = true
end)
tool.Unequipped:Connect(function()
EQ = false
end)
ui.InputBegan:Connect(function(type1,typing)
if typing then
return
elseif type1.KeyCode == Enum.KeyCode.Q and db == false and EQ == true then
db = true
local mouse = game.Players.LocalPlayer:GetMouse()
local char = player.Character
local NewLN = LN:Clone()
NewLN.CFrame = CFrame.new(mouse.Hit.Position.X,0, mouse.Hit.Position.Z)
NewLN.Parent = game.Workspace
NewLN.Touched:Connect(function(hit)
print("hi")
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum and hum ~= char.Humanoid then
print("humfound")
hum:TakeDamage(dmg)
end
end)
wait(1)
NewLN:Destroy()
wait(cd)
db = false
end
end)
I think they meant to say “network ownership”, but essentially if you damage the NPC using a LocalScript that damage will only be applied for that LocalScript’s player and the NPC will stay unharmed for everyone else. To solve this problem you’ll need to use a RemoteEvent to send a signal to the server when you want to damage the NPC and damage it within the server Script that has the OnServerEvent connection for the RemoteEvent