Issues with end

I have a sword script. Though i keep getting errors, eof or I have too many ends. So I delete the end it says that is giving an error message than tells me to put the end back in a different error message. I keep tinkering with it and nothing is working. Its just giving me the same dang error message!!!

local script:

local wind = Instance.new("Part", workspace)
wind.Shape = "Cylinder"
wind.Size = Vector3.new(0.7,30.1,74.3)
wind.BrickColor = BrickColor.new("Ghost grey")
wind.Anchored = true
wind.CanCollide = false
wind.Transparency = 1
wind.Material = "SmoothPlastic"

local Info = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,true,0)
local flash = game:GetService("TweenService"):Create(wind,Info,{Size = Vector3.new(1,100,100)})
local tool = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local InputService = game:GetService("UserInputService")
local InputType = Enum.UserInputType

local animation = nil
local slashAnimation = nil
local swing1 = nil
local wham1 = nil
tool.Equipped:Connect(function()
	animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://7118111810"
	slashAnimation = humanoid:LoadAnimation(animation)
	swing1 = Instance.new("Animation")
	swing1.AnimationId = "rbxassetid://7193950823"
	wham1 = humanoid:WaitForChild("Animator"):LoadAnimation(swing1)
end)

tool.Unequipped:Connect(function()
	animation:Destroy()
	slashAnimation = nil
	swing1:Destroy()
	wham1 = nil
end)



local hi = character:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")



UIS.InputBegan:Connect(function(key)

	if key.UserInputType == Enum.UserInputType.MouseButton3 then
		wham1:Play()
		wait(1)
		local playpos = CFrame.new(hi.Position)

		wind.CFrame = playpos
		local rotate = CFrame.Angles(0, math.rad(0), math.rad(90))
		wind.CFrame = wind.CFrame:ToWorldSpace(rotate)
		wind.Transparency = 0.25
		flash:Play()
		wind.Touched:Connect(function(partOther)
			local humanOther = partOther.Parent:FindFirstChild("Humanoid")
			if humanOther and humanOther.Parent ~= tool.Parent then
				game.ReplicatedStorage.RemoteEvent:FireServer(humanOther)
			end
	


end)

local debounce = false
InputService.InputBegan:Connect(function(input, processed)
			if input.UserInputType == InputType.MouseButton1 and slashAnimation and not processed then 
		if debounce then return end 
		debounce = true
		slashAnimation:Play()
		local Connection
		local tool = script.Parent

		local function onTouch(partOther)

			local humanOther = partOther.Parent:FindFirstChild("Humanoid")

			if not humanOther then return end

			if humanOther.Parent == tool then return end

			humanOther:TakeDamage(20)
		end

		Connection = tool:WaitForChild("Handle").Touched:Connect(onTouch)

		slashAnimation.Stopped:Wait() 
		debounce = false
		Connection:Disconnect()
			
				
			end
	end
local wind = Instance.new("Part", workspace)
wind.Shape = "Cylinder"
wind.Size = Vector3.new(0.7,30.1,74.3)
wind.BrickColor = BrickColor.new("Ghost grey")
wind.Anchored = true
wind.CanCollide = false
wind.Transparency = 1
wind.Material = "SmoothPlastic"

local Info = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,true,0)
local flash = game:GetService("TweenService"):Create(wind,Info,{Size = Vector3.new(1,100,100)})
local tool = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local InputService = game:GetService("UserInputService")
local InputType = Enum.UserInputType

local animation = nil
local slashAnimation = nil
local swing1 = nil
local wham1 = nil
tool.Equipped:Connect(function()
	animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://7118111810"
	slashAnimation = humanoid:LoadAnimation(animation)
	swing1 = Instance.new("Animation")
	swing1.AnimationId = "rbxassetid://7193950823"
	wham1 = humanoid:WaitForChild("Animator"):LoadAnimation(swing1)
end)

tool.Unequipped:Connect(function()
	animation:Destroy()
	slashAnimation = nil
	swing1:Destroy()
	wham1 = nil
end)



local hi = character:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")



UIS.InputBegan:Connect(function(key)

	if key.UserInputType == Enum.UserInputType.MouseButton3 then
		wham1:Play()
		wait(1)
		local playpos = CFrame.new(hi.Position)

		wind.CFrame = playpos
		local rotate = CFrame.Angles(0, math.rad(0), math.rad(90))
		wind.CFrame = wind.CFrame:ToWorldSpace(rotate)
		wind.Transparency = 0.25
		flash:Play()

		wind.Touched:Connect(function(partOther)
			local humanOther = partOther.Parent:FindFirstChild("Humanoid")

			if humanOther and humanOther.Parent ~= tool.Parent then
				game.ReplicatedStorage.RemoteEvent:FireServer(humanOther)
			end
		end)
	end
end)

local debounce = false
InputService.InputBegan:Connect(function(input, processed)
	if input.UserInputType == InputType.MouseButton1 and slashAnimation and not processed then 
		if debounce then return end 

		debounce = true
		slashAnimation:Play()
		local Connection
		local tool = script.Parent

		local function onTouch(partOther)

		local humanOther = partOther.Parent:FindFirstChild("Humanoid")

		if not humanOther then return end

		if humanOther.Parent == tool then return end
			humanOther:TakeDamage(20)
		end
	end
end)

Connection = tool:WaitForChild("Handle").Touched:Connect(onTouch)
	slashAnimation.Stopped:Wait() 
	debounce = false
	Connection:Disconnect()
end) --[[IF THIS DOESN'T WORK ON THIS LINE, ERASE THE PARENTHASIS.]]--

Give that a try. Let me know how it goes. I left a note on one of the last lines, give it a brief look-at.

1 Like

Doesnt work. Even if i remove the parentheses.

are there any errors? are they the same errors or different?

same errors…


What line do the errors occur on? can you tell me the code on the line?

Workspace.trueblockhead101.Stick.LocalScript:91: Expected ā€˜)’ (to close ā€˜(’ at line 72), got ā€˜end’

line 72:

InputService.InputBegan:Connect(function(input, processed)

You might be missing a ā€œend)ā€ that should be at line 65. And the very last end is missing a ā€œ)ā€

You forgot two different ends, both are here:

It should look like this:

	if key.UserInputType == Enum.UserInputType.MouseButton3 then
		wham1:Play()
		wait(1)
		local playpos = CFrame.new(hi.Position)

		wind.CFrame = playpos
		local rotate = CFrame.Angles(0, math.rad(0), math.rad(90))
		wind.CFrame = wind.CFrame:ToWorldSpace(rotate)
		wind.Transparency = 0.25
		flash:Play()
		wind.Touched:Connect(function(partOther)
			local humanOther = partOther.Parent:FindFirstChild("Humanoid")
			if humanOther and humanOther.Parent ~= tool.Parent then
				game.ReplicatedStorage.RemoteEvent:FireServer(humanOther)
			end
        end)
    end

i fixed my post, recopy it and paste it.

Still wont work, 16:11:05.639 Workspace.trueblockhead101.Stick.LocalScript:97: Expected , got ā€˜end’

yikes, i’d use other people’s help then, my head isn’t in the right place today lmao

local wind = Instance.new("Part", workspace)
wind.Shape = "Cylinder"
wind.Size = Vector3.new(0.7,30.1,74.3)
wind.BrickColor = BrickColor.new("Ghost grey")
wind.Anchored = true
wind.CanCollide = false
wind.Transparency = 1
wind.Material = "SmoothPlastic"

local Info = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,true,0)
local flash = game:GetService("TweenService"):Create(wind,Info,{Size = Vector3.new(1,100,100)})
local tool = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local InputService = game:GetService("UserInputService")
local InputType = Enum.UserInputType

local animation = nil
local slashAnimation = nil
local swing1 = nil
local wham1 = nil
tool.Equipped:Connect(function()
	animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://7118111810"
	slashAnimation = humanoid:LoadAnimation(animation)
	swing1 = Instance.new("Animation")
	swing1.AnimationId = "rbxassetid://7193950823"
	wham1 = humanoid:WaitForChild("Animator"):LoadAnimation(swing1)
end)

tool.Unequipped:Connect(function()
	animation:Destroy()
	slashAnimation = nil
	swing1:Destroy()
	wham1 = nil
end)



local hi = character:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")



UIS.InputBegan:Connect(function(key)

	if key.UserInputType == Enum.UserInputType.MouseButton3 then
		wham1:Play()
		wait(1)
		local playpos = CFrame.new(hi.Position)

		wind.CFrame = playpos
		local rotate = CFrame.Angles(0, math.rad(0), math.rad(90))
		wind.CFrame = wind.CFrame:ToWorldSpace(rotate)
		wind.Transparency = 0.25
		flash:Play()

		wind.Touched:Connect(function(partOther)
			local humanOther = partOther.Parent:FindFirstChild("Humanoid")

			if humanOther and humanOther.Parent ~= tool.Parent then
				game.ReplicatedStorage.RemoteEvent:FireServer(humanOther)
			end
		end)
	end
end)

local debounce = false
InputService.InputBegan:Connect(function(input, processed)
	if input.UserInputType == InputType.MouseButton1 and slashAnimation and not processed then 
		if debounce then return end 

		    debounce = true
		    slashAnimation:Play()
		    local Connection
		    local tool = script.Parent

		    local function onTouch(partOther)
		       local humanOther = partOther.Parent:FindFirstChild("Humanoid")

		       if not humanOther then return end

		       if humanOther.Parent == tool then return end
		   	   humanOther:TakeDamage(20)
            end-- the missing end for onTouch function
		end
	end
end)

Connection = tool:WaitForChild("Handle").Touched:Connect(function(hit)
	slashAnimation.Stopped:Wait() 
	debounce = false
	Connection:Disconnect()
end) --[[IF THIS DOESN'T WORK ON THIS LINE, ERASE THE PARENTHASIS.]]--

Your problem is with this line:

Connection = tool:WaitForChild("Handle").Touched:Connect(onTouch)

Firstly, it’s not connecting to a function, so why is there shouldn’t be an end after it (so delete the last end). Secondly, it’s referencing a local function called within another function, so when run, it will be unfamiliar with what onTouch is.

1 Like

You forgot a few end’s and parentheses.

local wind = Instance.new("Part", workspace)
wind.Shape = "Cylinder"
wind.Size = Vector3.new(0.7,30.1,74.3)
wind.BrickColor = BrickColor.new("Ghost grey")
wind.Anchored = true
wind.CanCollide = false
wind.Transparency = 1
wind.Material = "SmoothPlastic"

local Info = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,true,0)
local flash = game:GetService("TweenService"):Create(wind,Info,{Size = Vector3.new(1,100,100)})
local tool = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local InputService = game:GetService("UserInputService")
local InputType = Enum.UserInputType

local animation = nil
local slashAnimation = nil
local swing1 = nil
local wham1 = nil
tool.Equipped:Connect(function()
	animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://7118111810"
	slashAnimation = humanoid:LoadAnimation(animation)
	swing1 = Instance.new("Animation")
	swing1.AnimationId = "rbxassetid://7193950823"
	wham1 = humanoid:WaitForChild("Animator"):LoadAnimation(swing1)
end)

tool.Unequipped:Connect(function()
	animation:Destroy()
	slashAnimation = nil
	swing1:Destroy()
	wham1 = nil
end)



local hi = character:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")



UIS.InputBegan:Connect(function(key)

	if key.UserInputType == Enum.UserInputType.MouseButton3 then
		wham1:Play()
		wait(1)
		local playpos = CFrame.new(hi.Position)

		wind.CFrame = playpos
		local rotate = CFrame.Angles(0, 0, math.rad(90))
		wind.CFrame = wind.CFrame:ToWorldSpace(rotate)
		wind.Transparency = 0.25
		flash:Play()
		wind.Touched:Connect(function(partOther)
			local humanOther = partOther.Parent:FindFirstChild("Humanoid")
			if humanOther and humanOther.Parent ~= tool.Parent then
				game.ReplicatedStorage.RemoteEvent:FireServer(humanOther)
			end
		end)
    end
end)

local debounce = false
InputService.InputBegan:Connect(function(input, processed)
	if input.UserInputType == InputType.MouseButton1 and slashAnimation and not processed then 
		if debounce then return end 
		debounce = true
		slashAnimation:Play()
		local Connection
		local tool = script.Parent

		local function onTouch(partOther)

			local humanOther = partOther.Parent:FindFirstChild("Humanoid")

			if not humanOther then return end

			if humanOther.Parent == tool then return end

			humanOther:TakeDamage(20)
		end

		Connection = tool:WaitForChild("Handle").Touched:Connect(onTouch)

		slashAnimation.Stopped:Wait() 
		debounce = false
		Connection:Disconnect()			
    end
end)
1 Like