It's for a Anime RP game me and my friends dalton131, BuiltForNil have to use. I tried by just putting it in the tool but it won't work. When I try the tool out the blue words won't come out of my head :/ Idk whats wrong with it here's the whole script.
r = game:service("RunService")
local damage = 3 local slash_damage = 10
sword = script.Parent.Handle Tool = script.Parent
local SlashSound = Instance.new("Sound") SlashSound.SoundId = "rbxasset://sounds\swordslash.wav" SlashSound.Parent = sword SlashSound.Volume = .7
local LungeSound = Instance.new("Sound") LungeSound.SoundId = "rbxasset://sounds\swordlunge.wav" LungeSound.Parent = sword LungeSound.Volume = .6
local UnsheathSound = Instance.new("Sound") UnsheathSound.SoundId = "rbxasset://sounds\unsheath.wav" UnsheathSound.Parent = sword UnsheathSound.Volume = 1
function blow(hit) if (hit.Parent == nil) then return end -- happens when bullet hits sword
local humanoid = hit.Parent:findFirstChild("Humanoid") local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter) local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character if humanoid~=nil and humanoid ~= hum and hum ~= nil then -- final check, make sure sword is in-hand local right_arm = vCharacter:FindFirstChild("Right Arm") if (right_arm ~= nil) then local joint = right_arm:FindFirstChild("RightGrip") if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then tagHumanoid(humanoid, vPlayer) humanoid:TakeDamage(damage) wait(1) untagHumanoid(humanoid) end end end
end
function tagHumanoid(humanoid, player) local creator_tag = Instance.new("ObjectValue") creator_tag.Value = player creator_tag.Name = "creator" creator_tag.Parent = humanoid end
function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end
function swordAcross() -- parry end
Tool.Enabled = true local last_attack = 0 function onActivated()
SlashSound:play() if not Tool.Enabled then return end Tool.Enabled = false local character = Tool.Parent; local humanoid = character.Humanoid if humanoid == nil then print("Humanoid not found") return end t = r.Stepped:wait() --wait(.5) Tool.Enabled = true game:GetService("Chat"):Chat(Player.Character.Head,"Samehada, Release!")
end
function onEquipped() UnsheathSound:play() end
script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)
connection = sword.Touched:connect(blow)
game
is a global variable already available in the default function environment of every script. GetService
and service
are both analogous member functions of game
.