Hi hello. it's me again, the dude that has the worst scripts on this entire website
So, with the help of a user named blowup999 (go check them out), i have fixed my battle script
However another problem arose.
--Variables
local parts = game.Workspace.Parts:GetChildren()
local Players = game:GetService("Players")
local Dummy = game.Workspace.Dummy
local DummyHumanoid = Dummy.Humanoid
local debounce = false
local player = Players.LocalPlayer
local Character = player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local FadeInFrame = script.Parent.Parent.FadeInUI.FadeInFrame
--Battle Loop
for i, v in pairs(parts) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
script.Parent.Parent.FadeInUI.Enabled = true
FadeInFrame.BackgroundTransparency = 1
for k = 1,100 do
FadeInFrame.BackgroundTransparency -= 0.01
wait(0.05)
if FadeInFrame.BackgroundTransparency == 0 then
break
end
end
script.Parent.Parent.FadeInUI.Enabled = false
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
script.Parent.Enabled = true
Character:FindFirstChild("HumanoidRootPart").CFrame = game.Workspace.TpPart.CFrame + Vector3.new(0,1,0)
if script.Parent.Enabled == true then
if script.Parent.AtkSelector.Punch.MouseButton1Click then
script.Parent.AtkSelector.Punch.MouseButton1Click:Connect(function()
if not debounce then
debounce = true
DummyHumanoid.Health = DummyHumanoid.Health - 50
local function typeText(text)
for i = 1, #text do
script.Parent.DialogueLabel.Text = string.sub(text, 1, i)
wait()
end
wait(1.5)
script.Parent.DialogueLabel.Text = ""
end
if DummyHumanoid.Health <= 0 then
typeText("You won!")
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 40
script.Parent.AtkSelector.Punch.Visible = false
script.Parent.AtkSelector.Kick.Visible = false
script.Parent.AtkSelector.Cancel.Visible = false
script.Parent.Enabled = false
DummyHumanoid.Health = 100
debounce = false
v:Destroy()
else
script.Parent.AtkSelector.Visible = false
script.Parent.MagicSelector.Visible = false
wait(1)
typeText("This is the core battle system")
typeText("Isn't this cool???")
typeText("No??")
typeText("Welp, I tried")
Humanoid.Health = Humanoid.Health - 100
wait(1)
script.Parent.AtkSelector.Visible = true
script.Parent.MagicSelector.Visible = true
debounce = false
end
end
end)
end
end
end
end)
end
So, this is the entire script, i know its ugly and inefficient but hear me out on this one
So in this part
if DummyHumanoid.Health <= 0 then
typeText("You won!")
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 40
script.Parent.AtkSelector.Punch.Visible = false
script.Parent.AtkSelector.Kick.Visible = false
script.Parent.AtkSelector.Cancel.Visible = false
script.Parent.Enabled = false
DummyHumanoid.Health = 100
debounce = false
v:Destroy()
else
script.Parent.AtkSelector.Visible = false
script.Parent.MagicSelector.Visible = false
wait(1)
typeText("This is the core battle system")
typeText("Isn't this cool???")
typeText("No??")
typeText("Welp, I tried")
Humanoid.Health = Humanoid.Health - 100
wait(1)
script.Parent.AtkSelector.Visible = true
script.Parent.MagicSelector.Visible = true
debounce = false
Something is missing here. If you can't guess what it is, im just gonna tell you.
I did not conclude the possibility that the player can die, so, even if the player dies, this will go on forever.
I thought adding an elseif statement after the first if was gonna work
Something along the lines of this
if DummyHumanoid.Health <= 0 then
typeText("You won!")
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 40
script.Parent.AtkSelector.Punch.Visible = false
script.Parent.AtkSelector.Kick.Visible = false
script.Parent.AtkSelector.Cancel.Visible = false
script.Parent.Enabled = false
DummyHumanoid.Health = 100
debounce = false
v:Destroy()
elseif Humanoid.Health <= 0 then
typeText("Ded")
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 40
script.Parent.AtkSelector.Punch.Visible = false
script.Parent.AtkSelector.Kick.Visible = false
script.Parent.AtkSelector.Cancel.Visible = false
script.Parent.Enabled = false
DummyHumanoid.Health = 100
debounce = false
else
script.Parent.AtkSelector.Visible = false
script.Parent.MagicSelector.Visible = false
wait(1)
typeText("This is the core battle system")
typeText("Isn't this cool???")
typeText("No??")
typeText("Welp, I tried")
Humanoid.Health = Humanoid.Health - 100
wait(1)
script.Parent.AtkSelector.Visible = true
script.Parent.MagicSelector.Visible = true
debounce = false
end
Apparently, it doesn't, the battle UI stays visible after i die and the dummy does not get healed, nor the typeText() function runs.
I might be missing something obvious here, but i still need some help.
I'd appreciate any help you all can give. Thank you

1 comment
Works like a charm, thank you again, you've helped me twice and i appreciate all of it