It says "expected 'end' (to close function at line 8), got <eof>"
~ ~ ~
bin = script.Parent me = script.Parent.Parent.Parent enabled = true function Talk(msg) game:GetService("Chat"):Chat(me.Character.Head, msg, Enum.ChatColor.Red) end function KeyDown(key) if key == "z" then if not enabled then return end local player = game.Players.LocalPlayer if player == nil then return end --Here is how i disabled the tool from working after you click once "enabled = false" enabled = false LeftShoulder = me.Character.Torso["Left Shoulder"] RightShoulder = me.Character.Torso["Right Shoulder"] Neck = me.Character.Torso["Neck"] value1 = LeftShoulder.C0 value2 = RightShoulder.C0 value3 = Neck.C0 Run = game:GetService("RunService") RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(-0.5, 0, 0) LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(-0.5, 0, 0) wait(0.75) Neck.C0 = value3 RightShoulder.C0 = value2 LeftShoulder.C0 = value1 wait() RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 1.5) LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, -1.5) Talk("Air Blast!") game.Debris:AddItem(ShockWave2, 3) for a = 1,3 do local SavedTorsoCFrame = me.Character.Torso.CFrame ShockWave2 = Instance.new("Part") ShockWave2.Parent = Workspace ShockWave2.Size = Vector3.new(5,5,5) ShockWave2.formFactor = "Symmetric" ShockWave2.Anchored = true ShockWave2.Shape = "Block" ShockWave2.CanCollide = false ShockWave2.Transparency = 0 ShockWave2.TopSurface = "Smooth" ShockWave2.BottomSurface = "Smooth" ShockWave2.BrickColor = BrickColor.new("White") ShockWave2.CFrame = SavedTorsoCFrame * CFrame.new(0, 0, -10) * CFrame.Angles(1.57, 0, 0) m = Instance.new("SpecialMesh") m.Parent = ShockWave2 m.MeshType = "Sphere" m.Scale = Vector3.new(1, 1, 1) game.Debris:AddItem(ShockWave2, 3) for i = 1, 20 do wait(0.01) ShockWave1 = Instance.new("Part") ShockWave1.Parent = Workspace ShockWave1.Size = Vector3.new(5,5,5) ShockWave1.formFactor = "Symmetric" ShockWave1.Anchored = true ShockWave1.Shape = "Block" ShockWave1.CanCollide = false ShockWave1.Transparency = 0 ShockWave1.TopSurface = "Smooth" ShockWave1.BottomSurface = "Smooth" zomg = math.random(1, 2) if zomg == 1 then ShockWave1.BrickColor = BrickColor.new("Pastel light blue") end if zomg == 2 then ShockWave1.BrickColor = BrickColor.new("White") end ShockWave1.Name = "ShockWavePart" m = Instance.new("CylinderMesh") m.Parent = ShockWave1 m.Scale = Vector3.new(1, 1, 1) game.Debris:AddItem(ShockWave1, 2) ShockWave1.CFrame = SavedTorsoCFrame * CFrame.new(0, 0, -(i*20)) * CFrame.Angles(1.57, 0, 0) for u, c in pairs(workspace:GetChildren()) do if c.Name ~= me.Character.Name then h = c:findFirstChild("Humanoid") t = c:findFirstChild("Torso") if h ~= nil and t ~= nil then if (ShockWave1.Position-t.Position).magnitude <= 20 then h:TakeDamage(10) h.Sit = true end end end end end wait(1) end LeftShoulder.C0 = value1 RightShoulder.C0 = value2 wait(0.25) --Heres how long you want it to be before you use it again change wait(2) to anything u want wait(4) --Here is how i made it able to work again after the time has run out "enabled = true" enabled = true end --You can keep all this below i guess enabled = true function onS(key) key.KeyDown:connect(function() onKeyDown(key) end) end bin.Selected:connect(onS)
This is why tabbing your code correctly is very important.
Every time you start a block, increase your tabbing (with one tab). The ROBLOX script editor tries to help out with this.
Every time you stop a block, decrease your tabbing (and add the appropriate end
[or until
for repeat
]).
If we tab your code, we get this:
bin = script.Parent me = script.Parent.Parent.Parent enabled = true function Talk(msg) game:GetService("Chat"):Chat(me.Character.Head, msg, Enum.ChatColor.Red) end function KeyDown(key) if key == "z" then if not enabled then return end local player = game.Players.LocalPlayer if player == nil then return end --Here is how i disabled the tool from working after you click once "enabled = false" enabled = false LeftShoulder = me.Character.Torso["Left Shoulder"] RightShoulder = me.Character.Torso["Right Shoulder"] Neck = me.Character.Torso["Neck"] value1 = LeftShoulder.C0 value2 = RightShoulder.C0 value3 = Neck.C0 Run = game:GetService("RunService") RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(-0.5, 0, 0) LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(-0.5, 0, 0) wait(0.75) Neck.C0 = value3 RightShoulder.C0 = value2 LeftShoulder.C0 = value1 wait() RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 1.5) LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, -1.5) Talk("Air Blast!") game.Debris:AddItem(ShockWave2, 3) for a = 1,3 do local SavedTorsoCFrame = me.Character.Torso.CFrame ShockWave2 = Instance.new("Part") ShockWave2.Parent = Workspace ShockWave2.Size = Vector3.new(5,5,5) ShockWave2.formFactor = "Symmetric" ShockWave2.Anchored = true ShockWave2.Shape = "Block" ShockWave2.CanCollide = false ShockWave2.Transparency = 0 ShockWave2.TopSurface = "Smooth" ShockWave2.BottomSurface = "Smooth" ShockWave2.BrickColor = BrickColor.new("White") ShockWave2.CFrame = SavedTorsoCFrame * CFrame.new(0, 0, -10) * CFrame.Angles(1.57, 0, 0) m = Instance.new("SpecialMesh") m.Parent = ShockWave2 m.MeshType = "Sphere" m.Scale = Vector3.new(1, 1, 1) game.Debris:AddItem(ShockWave2, 3) for i = 1, 20 do wait(0.01) ShockWave1 = Instance.new("Part") ShockWave1.Parent = Workspace ShockWave1.Size = Vector3.new(5,5,5) ShockWave1.formFactor = "Symmetric" ShockWave1.Anchored = true ShockWave1.Shape = "Block" ShockWave1.CanCollide = false ShockWave1.Transparency = 0 ShockWave1.TopSurface = "Smooth" ShockWave1.BottomSurface = "Smooth" zomg = math.random(1, 2) if zomg == 1 then ShockWave1.BrickColor = BrickColor.new("Pastel light blue") end if zomg == 2 then ShockWave1.BrickColor = BrickColor.new("White") end ShockWave1.Name = "ShockWavePart" m = Instance.new("CylinderMesh") m.Parent = ShockWave1 m.Scale = Vector3.new(1, 1, 1) game.Debris:AddItem(ShockWave1, 2) ShockWave1.CFrame = SavedTorsoCFrame * CFrame.new(0, 0, -(i*20)) * CFrame.Angles(1.57, 0, 0) for u, c in pairs(workspace:GetChildren()) do if c.Name ~= me.Character.Name then h = c:findFirstChild("Humanoid") t = c:findFirstChild("Torso") if h ~= nil and t ~= nil then if (ShockWave1.Position-t.Position).magnitude <= 20 then h:TakeDamage(10) h.Sit = true end end end end end wait(1) end LeftShoulder.C0 = value1 RightShoulder.C0 = value2 wait(0.25) --Heres how long you want it to be before you use it again change wait(2) to anything u want wait(4) --Here is how i made it able to work again after the time has run out "enabled = true" enabled = true end enabled = true function onS(key) key.KeyDown:connect(function() onKeyDown(key) end) end bin.Selected:connect(onS)
Notice how when we get to the end, it's still "floating" away from the left. That means we missed an end
somewhere.
I'm guessing the end
should go before that final enabled = true
line (and that line should probably be deleted) -- it doesn't make sense to put functions in functions, especially since that one calls the one above it!
Thus the end of your script would look like
.... wait(0.25) --Heres how long you want it to be before you use it again change wait(2) to anything u want wait(4) --Here is how i made it able to work again after the time has run out "enabled = true" enabled = true end end function onS(key) key.KeyDown:connect(function() onKeyDown(key) end) end bin.Selected:connect(onS)
Beyond that, there are other problems.
Your function is named KeyDown
, but your event calls onKeyDown
.
You define variables (e.g., LeftShoulder
) but don't make them local
. You should always make variables local when it works (e.g., doesn't work for enabled
-- that one belongs as a global)
ROBLOX encourages :FindFirstChild
instead of :findFirstChild
.
You can just compare character objects instead of their names: if c ~= me.Character
It isn't possible for LocalPlayer
to be nil
when you're using a LocalScript.
You defined Run
inside of the function (it should belong at the top, since it doesn't change depending on when the function is run) but never use it
You use bad variable names like zomg
The thing for choosing brick color should probably just use else
.
If the first argument to math.random
is 1
, you can just drop it! math.random(1, 2)
is the same as math.random(2)
Because you don't have the right number of ends