Bruh, bruh, bruh.
Me need help, please. Im maked the function onDmg() and make the function checking on touched
if humanoid.Parent.Name ~= LocalPlayer.Name them
print(“Attacked is a”…attackNPC)
end
In the console writing the “Attacked the NPC-Thug”, not my player-nickname.
BUT ATTACKED HAS BEEN IM… bruhh… help me please
local function onDmgFSPOKE(hit)
if hit and hit.Parent:FindFirstChild('Humanoid') then
local hum = hit.Parent:FindFirstChild('Humanoid')
if hum.Parent.Name ~= game.Players.LocalPlayer.Name then
if damagePoke == true then
print("Attack is a "..hum.Parent.Name)
damagePoke = false
local damages = math.random(0.01, 0.05)
hum:TakeDamage(damages)
wait(0.01)
damagePoke = true
end
end
end
end
I do see a couple issues that could be changed about this script:
You could just define the Character instead of having to put hum.Parent each time you use it
I believe math.random will only accept integers (Or whole numbers) and not decimals, you could fix this by doing
local damages = math.random(100, 500) * 0.0001
A slight reminder that client-replication across the server will act very strange, so if the target dies the chances will only be made to the client, do use a RemoteEvent inside ReplicatedStorage to handle client-server transportation to be able to deal damage on the server side instead
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local function onDmgFSPOKE(hit)
if hit and hit.Parent:FindFirstChild('Humanoid') then
local Target = hit.Parent
local hum = Target:FindFirstChild('Humanoid')
if Target.Name ~= game.Players.LocalPlayer.Name and damagePoke == true then
print("Attack is a "..Target.Name)
damagePoke = false
local damages = math.random(0.01, 0.05) * 0.0001
Event:FireServer(Target, damages)
wait(0.01)
damagePoke = true
end
end
end
--ServerScript in ServerScriptService
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
Event.OnServerEvent:Connect(function(Player, Target, DamageResult)
Target.Humanoid:TakeDamage(DamageResult)
end)
First of all, please learn how to properly format a post so people can assist you better. Omit unnecessary remarks and keep straight to the point. Include your issue in your post title, and go into details in your post. Properly format your code using code blocks.
Second of all, this is a code snippet, and absolutely no context is given, so there’s not much anyone can do to help.
Currently, print("Attack is a "..hum.Parent.Name) will print the name of the “thing” that is being attacked. I’m not sure if this is what your goal is.
Doesn’t work. My later functions with damage NPC working succesfuly. They were writed in the LocalScript. With RemoveEvent, gives the “Attacked the NPC-Thug and taked the 0.016 damage”.
My script same how like your. With LocalScript he gives the same messages. But, this problem isn’t solved. Im died from the my damage, but func print writing that damaged the NPC. My nickname is CatMadeInHeaven, else, if was attacked im, im be died and func print writed that attacked im with how many damage. This function Touched has been setted to my hands. (Right and Left), and im makes the continion with check, who has been attacked, because dont die.
Im actually dont know why, im now doing checking the algorithm of script. If im detect the break logic of script, im say. And no, if im have the fast regeneration, then im not be died.
Probably, the break logic of script - this is my hands. Im maked the animation with touching hands. But… The condition who checked the name of character, where location of this hands, completing succesfuly, printed the name of enemy and no way hands can’t be the problem of breaking logic… Maybe, im create the connection of function to hands enemy?.. Hmmm… if this was true, then me need was go to enemy very near, but since, im taking damage on the distant of enemy… This is false, and, im use the punch and dont take the damage. If im attacked the enemy, im taking the damage… Im try to use function print when im use this “damage” function. Bruh, im using the punches, and function nothing wroted. Hmmm… If function nothing enter in the console, then… Сollision with something called the damage… Im tryed to attack the part, nothing happened. When im attacked the humanoid… Then… im take the damage… Hmm, maybe own condition problem to break logic of script.
BRUHHHHH… Im understand what happened. Im checking on .Touched:FindFirstChild(“Humanoid”)
if Part dont have the humanoid, the function doesnt be working. If im attacked the NPC, who have the humanoid, the code in function succesfuly complecting, im think that im just use own humanoid…