Hi I need help on fixing my Npc kill for cash script. I have been following a video.
How to make a Kill NPC For Cash Script ROBLOX Studio Tutorial - YouTube
I have look over at his script but I cant Find any thing.
What is the script that is in the sword? Copy and paste the code instead of the image, please.
It is just the Roblox sword right now
âRescripted by Luckymaxer
âEUROCOW WAS HERE BECAUSE I MADE THE PARTICLES AND THEREFORE THIS ENTIRE SWORD PRETTY AND LOOK PRETTY WORDS AND IâD LIKE TO DEDICATE THIS TO MY FRIENDS AND HI LUCKYMAXER PLS FIX SFOTH SWORDS TY LOVE YâALl
âUpdated for R15 avatars by StarWars
âRe-updated by TakeoHonorable
Tool = script.Parent
Handle = Tool:WaitForChild(âHandleâ)
function Create(ty)
return function(data)
local obj = Instance.new(ty)
for k, v in pairs(data) do
if type(k) == ânumberâ then
v.Parent = obj
else
obj[k] = v
end
end
return obj
end
end
local BaseUrl = ârbxassetid://â
Players = game:GetService(âPlayersâ)
Debris = game:GetService(âDebrisâ)
RunService = game:GetService(âRunServiceâ)
DamageValues = {
BaseDamage = 5,
SlashDamage = 10,
LungeDamage = 30
}
âFor R15 avatars
Animations = {
R15Slash = 522635514,
R15Lunge = 522638767
}
Damage = DamageValues.BaseDamage
Grips = {
Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
}
Sounds = {
Slash = Handle:WaitForChild(âSwordSlashâ),
Lunge = Handle:WaitForChild(âSwordLungeâ),
Unsheath = Handle:WaitForChild(âUnsheathâ)
}
ToolEquipped = false
âFor Omega Rainbow Katana thumbnail to display a lot of particles.
for i, v in pairs(Handle:GetChildren()) do
if v:IsA(âParticleEmitterâ) then
v.Rate = 20
end
end
Tool.Grip = Grips.Up
Tool.Enabled = true
function IsTeamMate(Player1, Player2)
return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new(âObjectValueâ)
Creator_Tag.Name = âcreatorâ
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA(âObjectValueâ) and v.Name == âcreatorâ then
v:Destroy()
end
end
end
function Blow(Hit)
if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
return
end
local RightArm = Character:FindFirstChild(âRight Armâ) or Character:FindFirstChild(âRightHandâ)
if not RightArm then
return
end
local RightGrip = RightArm:FindFirstChild(âRightGripâ)
if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
return
end
local character = Hit.Parent
if character == Character then
return
end
local humanoid = character:FindFirstChildOfClass(âHumanoidâ)
if not humanoid or humanoid.Health == 0 then
return
end
local player = Players:GetPlayerFromCharacter(character)
if player and (player == Player or IsTeamMate(Player, player)) then
return
end
UntagHumanoid(humanoid)
TagHumanoid(humanoid, Player)
humanoid:TakeDamage(Damage)
end
function Attack()
Damage = DamageValues.SlashDamage
Sounds.Slash:Play()
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Slash"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Slash")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
end
end
function Lunge()
Damage = DamageValues.LungeDamage
Sounds.Lunge:Play()
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Lunge"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Lunge")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
end
--[[
if CheckIfAlive() then
local Force = Instance.new("BodyVelocity")
Force.velocity = Vector3.new(0, 10, 0)
Force.maxForce = Vector3.new(0, 4000, 0)
Debris:AddItem(Force, 0.4)
Force.Parent = Torso
end
]]
wait(0.2)
Tool.Grip = Grips.Out
wait(0.6)
Tool.Grip = Grips.Up
Damage = DamageValues.SlashDamage
end
Tool.Enabled = true
LastAttack = 0
function Activated()
if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
return
end
Tool.Enabled = false
local Tick = RunService.Stepped:wait()
if (Tick - LastAttack < 0.2) then
Lunge()
else
Attack()
end
LastAttack = Tick
âwait(0.5)
Damage = DamageValues.BaseDamage
local SlashAnim = (Tool:FindFirstChild(âR15Slashâ) or Create(âAnimationâ){
Name = âR15Slashâ,
AnimationId = BaseUrl ⌠Animations.R15Slash,
Parent = Tool
})
local LungeAnim = (Tool:FindFirstChild("R15Lunge") or Create("Animation"){
Name = "R15Lunge",
AnimationId = BaseUrl .. Animations.R15Lunge,
Parent = Tool
})
Tool.Enabled = true
end
function CheckIfAlive()
return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent) and true) or false)
end
function Equipped()
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChildOfClass(âHumanoidâ)
Torso = Character:FindFirstChild(âTorsoâ) or Character:FindFirstChild(âHumanoidRootPartâ)
if not CheckIfAlive() then
return
end
ToolEquipped = true
Sounds.Unsheath:Play()
end
function Unequipped()
Tool.Grip = Grips.Up
ToolEquipped = false
end
Tool.Activated:Connect(Activated)
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)
Connection = Handle.Touched:Connect(Blow)
What I am seeing is a mistake in your code writing. You wrote âFindFristChildâ
This should work for you:
local Humanoid = script.Parent.Humanoid
function Dead()
local tag = Humanoid:FindFirstChild("creator")
if tag ~= nil then
local leaderstats = tag.Value:FindFirstChild("leaderstats")
if leaderstats ~= nil then
leaderstats.Cash.Value = leaderstats.Cash.Value + 10
wait(0.1)
script:Remove()
end
end
end
end
Humanoid.Died:Connect(Dead)
Hope it helps
Ok I will try that thank you.adwdaw
Thank you so much It works Now.
Although there is already a solution, I think it might be worth using a âsmart tagâ as well.
local function StartTag(hum, dmg, plr)
if not (hum.Health - dmg > 0) and not hum:FindFirstChild("creator") then -- If the subtracted damage from the health isn't greater than 0 and there isn't a `creator` tag, then...
local tag = Instance.new("ObjectValue")
tag.Name = "creator"
tag.Value = plr
tag.Parent = hum
-- return true
end
-- return false
end
This would allow only the player who killed the other player first to be tagged.
ok thank you for the suggestion.