Achieve
I am attempting to achieve the red death effect when being damaged by this tool.
Issue
The issue is quite simple, it will not appear. No matter what I do, it will not appear.
Explanation
When I state the red death effect, this is what I mean. The red effect around the screen.
The Script
This is a long script, brace yourself.
--[Wrestling Clean Edition By TerryMichaelBrunk,Samaclub & MillerrIAm]--
----------------[Variables]----------------
local r = game:service("RunService")
local sword = script.Parent.Handle
local Tool = script.Parent
local plr = game.Players
local GUIFolder = script.Parent.GUIs
--[GUI Names]--
local GUIs = {"BrokenGUI","PlayerDelagGUI"}
--[Values]--
local damage = 0
local slash_damage = .5
local lunge_damage = 2.8
local debounce = false
----------------[Main Script]----------------
--[Blow Function]--
function blow(hit)
if not debounce then
debounce = true
print("Running")
local humanoid = hit.Parent:findFirstChild("Humanoid")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local hum = vCharacter:findFirstChild("Humanoid")
if humanoid~=nil and humanoid ~= hum and hum ~= nil then
humanoid.Health = humanoid.Health - damage
end
game:GetService("RunService").Stepped:Wait()
debounce = false
tagHumanoid(humanoid, vPlayer)
wait(1)
untagHumanoid(humanoid)
end
end
--[Tag Humanoid Function]--
function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end
--[Untag Humanoid Function]--
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end
--[Attack Function]--
function attack()
damage = slash_damage
local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
end
--[Lunge Function]--
function lunge()
damage = lunge_damage
local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Lunge"
anim.Parent = Tool
local force = Instance.new("BodyVelocity")
force.velocity = Vector3.new(0,10,0)
force.maxForce = Vector3.new(0,0,0)
force.Parent = Tool.Parent.Torso
wait(.25)
swordOut()
wait(.25)
force.Parent = nil
wait(.5)
swordUp()
damage = slash_damage
end
--[Sword Up Function]--
function swordUp()
Tool.Handle.CanCollide = false
Tool.GripForward = Vector3.new(-1,0,0)
Tool.GripRight = Vector3.new(0,1,0)
Tool.GripUp = Vector3.new(0,0,1)
Tool.Handle.CanCollide = true
end
--[Sword Out Function]--
function swordOut()
Tool.Handle.CanCollide = false
Tool.GripForward = Vector3.new(0,0,1)
Tool.GripRight = Vector3.new(0,-1,0)
Tool.GripUp = Vector3.new(-1,0,0)
Tool.Handle.CanCollide = true
end
--[Tool Function]--
Tool.Enabled = true
local last_attack = 0
function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
return
end
local t = r.Stepped:wait()
if (t - last_attack < .2) then
lunge()
else
attack()
end
last_attack = t
Tool.Enabled = true
end
--[GUI Give Function]--
script.Parent.Equipped:Connect(function()
for i,GUIName in pairs(GUIs) do
if not plr[script.Parent.Parent.Name].PlayerGui:FindFirstChild(GUIName) then
GUIFolder[GUIName]:Clone().Parent = plr[script.Parent.Parent.Name].PlayerGui
end
end
end)
--[GUI Remove Function]--
script.Parent.Unequipped:Connect(function()
for i,GUIName in pairs(GUIs) do
if plr[script.Parent.Parent.Parent.Name].PlayerGui:FindFirstChild(GUIName) then
plr[script.Parent.Parent.Parent.Name].PlayerGui[GUIName]:Destroy()
end
end
end)
--[Activation]--
script.Parent.Activated:connect(onActivated)
sword.Touched:Connect(function(hit)
blow(hit)
end)
Side Note
I also realized that when you’re using a sword, the red death effect or the damage effect doesn’t appear either.
Thank you to anyone who helps me with this issue.