Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

im kinda confused for my script where do I put the ends so it stops getting errors?

Thank you for reading please help fix this

local debounce = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local animInstance = Instance.new("Animation")
local humanoid = character:WaitForChild("Humanoid")
animInstance.AnimationId = "rbxassetid://6380434675"
local anim = humanoid:LoadAnimation(animInstance)
local Col = game:GetService("CollectionService")
local tag = Col:GetTagged("Rain")
local torso = game.Workspace:FindFirstChild(player.Name)
mouse.KeyDown:connect(function(key)
	if key == "e" then
		if not debounce then
			torso.UpperTorso.Anchored = true
			anim:Play()
			local n = 10
			for i = 1, n do
				wait(0.5)
				torso.UpperTorso.Anchored = false
			for _, TaggedPart in pairs(tag) do
					local part = TaggedPart:Clone()
			part.Parent = game.Workspace
				part.Position = torso.UpperTorso.Position +(torso.UpperTorso.CFrame.lookVector*20) + Vector3.new(0,50,0)
					if part.Touched:Connect(function(hit)
						local player = game.Players.LocalPlayer
						local humanoid = game.Workspace:FindFirstChild(player.Name).Humanoid
						humanoid.Health = humanoid.Health - 30
					

	

				
						end
				end
			end
			
			end
		end
	end
end)                     
	

3 comments

0

All my homies hate mouse

0

I hope you were referring to KeyDown instead of the mouse itself lul

0

KeyDown is deprecated, use UserInputService.

1 answer

✓ Accepted answer
local debounce = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local animInstance = Instance.new("Animation")
local humanoid = character:WaitForChild("Humanoid")
animInstance.AnimationId = "rbxassetid://6380434675"
local anim = humanoid:LoadAnimation(animInstance)
local Col = game:GetService("CollectionService")
local tag = Col:GetTagged("Rain")
local torso = game.Workspace:FindFirstChild(player.Name)

mouse.KeyDown:connect(function(key)
	if key == "e" then
		if not debounce then
			torso.UpperTorso.Anchored = true
			anim:Play()
			local n = 10
			for i = 1, n do
				wait(0.5)
				torso.UpperTorso.Anchored = false
				for _, TaggedPart in pairs(tag) do
					local part = TaggedPart:Clone()
					part.Parent = game.Workspace
					part.Position = torso.UpperTorso.Position +(torso.UpperTorso.CFrame.lookVector*20) + Vector3.new(0,50,0)
					if part.Touched:Connect(function(hit)
						local player = game.Players.LocalPlayer
						local humanoid = game.Workspace:FindFirstChild(player.Name).Humanoid
						humanoid.Health = humanoid.Health - 30
					end
				end
			end
		end
	end
end)                     

1 comment

0

why did people downvote my answer?

This discussion is preserved as it was. New answers, comments, and votes are closed.