I have one script that controls all the mechanics in a game, but it won’t work and I don’t know exactly what’s wrong with it.
local MechanicsFolder = script.Parent
for i, part in pairs(MechanicsFolder:GetChildren()) do
part.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
if part.Name == "_Heal" and part:IsA("BasePart") then
Humanoid.Health = 100
end
if part.Name == "_Kill" and part:IsA("BasePart") then
Humanoid.Health = 0
end
if part.Name == "_Hurt" and part:IsA("BasePart") then
local HurtVal = part:FindFirstChild("Damage")
if HurtVal then
Humanoid.Health -= HurtVal.Value
else
Humanoid.Health -= 5
end
end
if part.Name == "_Speed" and part:IsA("BasePart") then
local SpeedVal = part:FindFirstChild("WalkSpeed")
local SpeedNum = 32
if SpeedVal then
SpeedNum = SpeedVal.Value
else
SpeedNum = 32
end
Humanoid.WalkSpeed = SpeedNum
end
if part.Name == "_Launch" and part:IsA("BasePart") then
local LaunchVal = part:FindFirstChild("Launch")
local LaunchNum = 40
if LaunchVal then
LaunchNum = LaunchVal.Value
else
LaunchNum = 40
end
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Velocity = Vector3.new(0, LaunchNum, 0)
bodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.P = math.huge
bodyVelocity.Parent = Humanoid.Parent.HumanoidRootPart
wait(0.5)
bodyVelocity:Destroy()
end
if part.Name == "_Free" and part:IsA("BasePart") then
-- Make your own!
end
end
end)
end