I've been working on this for a while now, but all of my ideas have failed. I made a block that appears in front of the player when they press a button and expands for a bit before disappearing. It's supposed to damage anything that it touches once as long as it has a humanoid, but things that don't move are never detected.
f = script.Parent.Touched:connect(function(hit)
local x = hit.Parent:FindFirstChild("Humanoid")
if x then
f:disconnect()
x:TakeDamage(math.random(2, 5))
end
end)
This is the part of the code that damages humanoids. The rest of the code is in separate scripts (I plan on cleaning things up later). The block is summoned when you press a button. I'll show the other two scripts:
Expanding script (child of a part named Skull):
cf = script.Parent.CFrame
num = 0.3
for i = 1, 4, 0.1 do
script.Parent.Size = Vector3.new(i, i, i)
script.Parent.Mesh.Scale = script.Parent.Mesh.Scale + Vector3.new(num, num, num)
script.Parent.CFrame = cf
wait()
end
for i = 0, 1, 0.1 do
script.Parent.Transparency = i
wait()
end
script.Parent:Destroy()
Summoning script (local script in StarterGui; ignore that there's no delay between presses yet):
p = game.Players.LocalPlayer
m = p:GetMouse()
m.KeyDown:connect(function(k)
if k == "z" then
local c = p.Character
local anim = script.Animation
local animPlay = c.Humanoid:LoadAnimation(anim)
animPlay:Play()
wait(0.3)
local x = game.ReplicatedStorage.Skull:Clone()
x.CFrame = c.Torso.CFrame * CFrame.new(5, 0, 0)
x.CFrame = x.CFrame * CFrame.Angles(0, 300, 0)
x.Parent = workspace
end
end)
Any help is appreciated. I've been trying hard to fix this myself.
