local ReplicatedStorage = game:GetService("ReplicatedStorage")
local M1 = ReplicatedStorage.RemoteEvents.Combat.M1
local M1Stop = ReplicatedStorage.RemoteEvents.Combat.M1Stop
local OnHitAnim = ReplicatedStorage.Animations.OnHit
local hitcolor = Color3.new(0.737255, 0, 0)
local function onhit (character)
local OnHitTrack = character.Humanoid:LoadAnimation(OnHitAnim)
OnHitTrack:Play(0.1,1,2.25)
for i,characterpart in pairs(character:GetChildren()) do
if characterpart:IsA("Part") or characterpart:IsA("MeshPart") then
characterpart.Color = hitcolor
-- change color back to normal
end
end
end
M1.OnServerEvent:Connect(function(player,Damage,AnimationPlaying)
local fireray = Ray.new(player.Character.HumanoidRootPart.Position,player.Character.HumanoidRootPart.CFrame.LookVector * 3.45)
local human = player.Character.Humanoid
local commands = {
blocking = player.Character.Blocking
}
local hit,position = game.Workspace:FindPartOnRayWithIgnoreList(fireray,{script.Parent})
if hit then
if hit.Name == ("HitBox") then
print(hit.Name,hit.Parent)
hit.Parent.Health = hit.Parent.Health - Damage
onhit(hit.Parent.Parent)
end
end
if AnimationPlaying == true then
for i,command in pairs(commands) do
command.Disabled = true
end
end
end)
M1Stop.OnServerEvent:Connect(function(player,AnimationPlaying)
local commands = {
blocking = player.Character.Blocking
}
if AnimationPlaying == false then
for i,command in pairs(commands) do
command.Disabled = false
end
end
end)
https://gyazo.com/9ff8e1a56e78b8d86382fd444d42bc97
So my problems are:
-
Idk how to really set the characters skin color back to normal after it changes red to indicate that it got hit maybe i store the characters normal color in a table or smth but idk
-
if possible how would i make a small overlay of the skin and make it red instead of making the character skin red because in the gyazo clip the clothing dosnt change colors
-
any good hit sounds because im to poor for 20 robux