WARNING!!!
If you get triggered by inefficient scripts i advise you to not view this one If you wish to help, then, you've been warned
Prepare for eye torture
--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
for k = 1,100 do
FadeInFrame.BackgroundTransparency -= 0.005
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 - 25
local function typeText(text)
for i = 1, #text do
script.Parent.DialogueLabel.Text = string.sub(text, 1, i)
wait()
end
wait(3)
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
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 - 10
wait(1)
script.Parent.AtkSelector.Visible = true
script.Parent.MagicSelector.Visible = true
debounce = false
end
end
end)
end
end
end
end)
end
If you actually managed to get through this cluster hell, congrats, you're a trooper. But now i need your help.
So, i want to create a battle system but i am as terrible at scripting as i am at life, even though i love scripting
So, let me explain all this you saw
I have a folder of parts in the workspace that when any of these parts are touched by the player, all of the script begins to work.
Everything goes swimmingly the first time, but when i try to re - enter the fight (since there will be multiple of them) some ... things happen
If you noticed, at the start of the script i have this
for k = 1,100 do
FadeInFrame.BackgroundTransparency -= 0.005
wait(0.05)
if FadeInFrame.BackgroundTransparency == 0 then
break
end
end
script.Parent.Parent.FadeInUI.Enabled = false
This is a fade in frame, so when i touch any of the parts, the screen starts turning white and then the frame disappears as the player gets teleported in front of the Dummy for the fight to begin.
Well, the first time this worked amazingly, though the second time... well uhh...
It did not, well, sort of, the screen immediately turned white and after some seconds i was teleported to where i had to be.
I did not really bother with that, i said to myself "eh it's alright i will find some help with that" but that was not the only problem
When i get teleported to the fight after i've already won, i can't damage the dummy
Yep, you've heard me, the script flat out breaks there and i can't do anything about it.
If you know how to help me (without telling me "make your script more efficient", which wouldn't actually be a bad idea) I'd appreciate it.
Again, I'm sorry for all this hell i caused

1 comment
"Wow this script is efficient!"... said no one ever