local char = script.Parent
local head = char:WaitForChild("Head")
local humanoidAnomaly = char:WaitForChild("Humanoid")
local shirt = char:WaitForChild("Shirt")
local pants = char:WaitForChild("Pants")
local effectMGR = require(game:GetService("ReplicatedStorage").EffectManager)
-- Original --
local description = humanoidAnomaly:GetAppliedDescription()
local shirtID = shirt.ShirtTemplate
local pantsID = pants.PantsTemplate
local anim = "rbxassetid://17897557091"
local ws = humanoidAnomaly.WalkSpeed
local jh = humanoidAnomaly.JumpHeight
local disguised = false
-- Other --
local helloSound = head:WaitForChild("Hello")
local iloveYouSound = head:WaitForChild("IL")
local ScreamVictim = head:WaitForChild("Scream")
local screamVictim2 = head:WaitForChild("Scream2")
local screamKiller = head:WaitForChild("Roar")
local killSound = head:WaitForChild("Kill")
local HRP = char:WaitForChild("HumanoidRootPart")
local censor = HRP:WaitForChild("Censor")
local splatter = HRP:WaitForChild("Splatter")
local inputEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("ActorInput")
local debounce = false
local runService = game:GetService("RunService")
-- Tear out of Skin anim --
local animator = humanoidAnomaly:WaitForChild("Animator")
local tearAnim = Instance.new("Animation")
tearAnim.AnimationId = anim
local tearAnimationTrack = animator:LoadAnimation(tearAnim)
-- Slash Attack anim
local dmg = 20
local swingSound = char:WaitForChild("Right Arm"):WaitForChild("Swing")
local slashSound = char:WaitForChild("Right Arm"):WaitForChild("Slash")
local hitbox = require(game:GetService("ReplicatedStorage").RaycastHitboxV4)
local slashHitbox = hitbox.new(char)
local animID = "rbxassetid://18109626006"
local slashAnim = Instance.new("Animation")
slashAnim.AnimationId = animID
local slashAnimationTrack = animator:LoadAnimation(slashAnim)
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {char} --- remember to define our character!
Params.FilterType = Enum.RaycastFilterType.Exclude
slashHitbox.Visualizer = false
slashHitbox.OnHit:Connect(function(hit, humanoid)
if humanoid.Parent ~= char then
local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
if player.Neutral or player.Team.Name ~= "Anomaly" then
slashSound:Play()
local rng = math.random(1,10)
humanoid:TakeDamage(dmg)
if rng == 1 then
effectMGR.AddEffect(humanoid.Parent,"Bleeding")
end
end
end
end)
local function Slash()
swingSound:Play()
slashHitbox:HitStart()
slashAnimationTrack:Play()
slashAnimationTrack.Ended:Wait()
slashHitbox:HitStop()
end
local function Undisguise(variable, debounce)
tearAnimationTrack:Play()
tearAnimationTrack:GetMarkerReachedSignal("TearEvent"):Connect(function()
variable = false
disguised = false
killSound:Play()
splatter:Emit(50)
humanoidAnomaly:ApplyDescription(description, Enum.AssetTypeVerification.Always)
shirt.ShirtTemplate = shirtID
pants.PantsTemplate = pantsID
local parts = workspace:GetPartBoundsInRadius(HRP.Position, 5)
for _, part in pairs(parts) do
if part:IsA("Part") and game:GetService("Players"):GetPlayerFromCharacter(part.Parent) then
local humanoid = part.Parent:FindFirstChild("Humanoid")
local jh = humanoid.JumpHeight
if humanoid ~= char:FindFirstChild("Humanoid") then
if humanoid then
local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
if player ~= game:GetService("Players"):GetPlayerFromCharacter(char) then
if player then
if player.Neutral or player.Team.Name ~= "Anomaly" then
humanoid.JumpHeight = 0
humanoid.Sit = true
task.wait(1)
humanoid.JumpHeight = jh
humanoid.Sit = false
end
end
end
end
end
end
end
end)
end
local function Slaughter(victim, var)
local victimTeam = game:GetService("Players"):GetPlayerFromCharacter(victim).Team
local victimPlr = game:GetService("Players"):GetPlayerFromCharacter(victim)
if not victimPlr.Neutral and victimTeam.Name == "Anomaly" then return end
humanoidAnomaly.WalkSpeed = 0
humanoidAnomaly.JumpHeight = 0
local humanoidVictim = victim:FindFirstChild("Humanoid")
humanoidVictim.WalkSpeed = 0
humanoidVictim.JumpHeight = 0
censor.Enabled = true
screamKiller:Play()
task.wait(0.05)
ScreamVictim:Play()
task.wait(0.2)
screamVictim2:Play()
task.wait(1)
killSound:Play()
splatter:Emit(500)
local victimShirt = victim:FindFirstChild("Shirt")
local victimPants = victim:FindFirstChild("Pants")
humanoidAnomaly:ApplyDescription(humanoidVictim:GetAppliedDescription(),Enum.AssetTypeVerification.Always)
shirt.ShirtTemplate = victimShirt.ShirtTemplate
pants.PantsTemplate = victimPants.PantsTemplate
humanoidVictim:TakeDamage(999999999999999)
task.wait(0.1)
censor.Enabled = false
humanoidAnomaly.WalkSpeed = ws
humanoidAnomaly.JumpHeight = jh
disguised = true
var = true
if humanoidVictim.Health > 0 then
humanoidVictim.WalkSpeed = 16
humanoidVictim.JumpHeight = 7.2
humanoidAnomaly:ApplyDescription(description, Enum.AssetTypeVerification.Always)
shirt.ShirtTemplate = shirtID
pants.PantsTemplate = pantsID
print("Kill failed.")
disguised = false
var = false
end
end
inputEvent.OnServerEvent:Connect(function(plr, input, mouseInput)
if plr.Character ~= char then return end
if debounce == true then return end
local inputToUse = string.lower(input)
if inputToUse == "e" then -- Voiceline 1 | "Hello?"
debounce = true
helloSound:Play()
helloSound.Ended:Wait()
debounce = false
elseif inputToUse == "q" then -- Voiceline 2 | "I love you"
debounce = true
iloveYouSound:Play()
iloveYouSound.Ended:Wait()
debounce = false
elseif disguised == false and inputToUse == "f" then -- Shapeshift into nearest person (killing them)
debounce = true
local parts = workspace:GetPartBoundsInRadius(HRP.Position, 1.8)
for _, part in pairs(parts) do
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid ~= char:FindFirstChild("Humanoid") then
if humanoid then
local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
if player ~= game:GetService("Players"):GetPlayerFromCharacter(char) then
if player then
if player.Neutral or player.Team.Name ~= "Anomaly" then
Slaughter(humanoid.Parent, disguised)
debounce = false
return
end
end
end
end
end
end
debounce = false
elseif disguised == true and inputToUse == "f" then -- if disguised, undisguise
debounce = true
Undisguise(disguised, debounce)
debounce = false
elseif disguised == false and mouseInput == Enum.UserInputType.MouseButton1 then
debounce = true
Slash()
debounce = false
end
end)
Code I’m interested in:
elseif disguised == false and inputToUse == "f" then -- Shapeshift into nearest person (killing them)
debounce = true
local parts = workspace:GetPartBoundsInRadius(HRP.Position, 1.8)
for _, part in pairs(parts) do
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid ~= char:FindFirstChild("Humanoid") then
if humanoid then
local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
if player ~= game:GetService("Players"):GetPlayerFromCharacter(char) then
if player then
if player.Neutral or player.Team.Name ~= "Anomaly" then
Slaughter(humanoid.Parent, disguised)
debounce = false
return
end
end
end
end
end
end
debounce = false
How would I make it so that multiple raycasts are cast that check whether the nearest player is obstructed (by a wall or so) in a radius?
Optionally, I’d also like to make it get ONE player in the radius only.
Do note: I am not familiar with math functions at all, if they’re required, do provide several explanations.