Hello, I was making a RemoteEvent for my Pain script, and it doesn't seem like the RemoteEvent works. (I removed the RemoteEvent function,) does anyone can guide me to use RemoteEvent? I am new at using it:

local u = game:GetService("UserInputService")
local remote = game:GetService("ReplicatedStorage").MONIKAMMMMMMMMLOLZEXPLOTIERSA
local t = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local human = character:FindFirstChild("Humanoid") or character:WaitForChild("Humanoid")
local cooldown = true
local animationid = "rbxassetid://02759884771"
local animate
local explosionlimit = 1
local get
u.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.One then
		if cooldown == true then
		
		cooldown = false
		
		local animation = Instance.new("Animation")
		remote:FireServer(animation)
		animation.AnimationId = animationid
		animation.Parent = character
		
		
		character:FindFirstChild("Humanoid").WalkSpeed = 0
		character:FindFirstChild("HumanoidRootPart").Anchored = true
		local goal1 = {}
		goal1.CFrame = CFrame.new(character:FindFirstChild("HumanoidRootPart").Position, Vector3.new(mouse.Hit.p.X, character:FindFirstChild("HumanoidRootPart").CFrame.Y, mouse.Hit.p.Z))
		
		local g1 = t:Create(character:FindFirstChild("HumanoidRootPart"), TweenInfo.new(0.5), goal1)
		g1:Play()
		
		local symbol = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.PainSymbol:Clone()
		symbol.Parent = game.Workspace
		symbol.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,-3,0)
		
		local aol = {}
		aol.Size = Vector3.new(20, 0.05, 20)
		aol.Orientation = Vector3.new(0,character:FindFirstChild("HumanoidRootPart").Orientation.Y,0)
		
		local a1 = t:Create(symbol, TweenInfo.new(0.5), aol)
		a1:Play()
		
		local pain = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.Blood:Clone()
		remote:FireServer(pain)
		pain.Parent = game.Workspace
		pain.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,5,0)
		pain.Transparency = 1
		
		local trans = {}
		trans.Transparency = 0
		
		local t1 = t:Create(pain, TweenInfo.new(2), trans)
		t1:Play()
		
		local attachment1 = Instance.new("Attachment")
		attachment1.Parent = pain
		
		local attachment0 = Instance.new("Attachment")
		attachment0.Parent = character:FindFirstChild("HumanoidRootPart")
		
		local beam = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.Bloodbeam:Clone()
		beam.Parent = pain
		beam.Attachment1 = attachment1
		beam.Attachment0 = attachment0
		
		wait(0.07)
		
		animate = human:LoadAnimation(animation)
		animate:Play()
	
		
		wait(0.7)
		
		character:FindFirstChild("Humanoid").WalkSpeed = 16
		character:FindFirstChild("HumanoidRootPart").Anchored = false
	
		wait(0.1)
		
		local goal = {}
		goal.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,8,-45)
		
		local g = t:Create(pain, TweenInfo.new(0.5), goal)
		g:Play() 
		
		wait(0.2)
		
		local goal2 = {}
		goal2.CFrame = CFrame.new(mouse.Hit.p.X,mouse.Hit.p.Y,mouse.Hit.p.Z)
	
		local g2 = t:Create(pain, TweenInfo.new(0.3), goal2)
		g2:Play()
				
		pain.Touched:Connect(function(hit)
			if explosionlimit == 1 then
			--if not hit.Name == player.Name and player.AccountAge then
				explosionlimit = 2
			
				print("yay")
				local expl = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.PainExplode:Clone()
				expl.Transparency = 0
				expl.Parent = workspace
				expl.CFrame = pain.CFrame * CFrame.new(0,0, 0)
					
				local go = {}
				go.Size = Vector3.new(50,50,50)
				go.Transparency = 1
					
				local g1g = t:Create(expl, TweenInfo.new(0.5), go)
				g1g:Play()
					
					
				wait(0.5)
				pain:Destroy()	
				expl.Anchored = false
				wait(5)	
				expl:Destroy()
				if hit.Parent:FindFirstChildOfClass("Humanoid") or not hit.Parent:FindFirstChildOfClass("Humanoid") then
				explosionlimit = 1	
					
				end
			--end
			end
		end)
		pain.Anchored = false
		
		wait(1)
		pain:Destroy()
		
		local symb = {}
		symb.Size = Vector3.new(0.05,0.05,0.05)

		local sy1 = t:Create(symbol, TweenInfo.new(0.2), symb)
		sy1:Play()		
		
		wait(1)
		symbol:Destroy()
		
		wait(4)
		
		cooldown = true
		
		
		end
	end
end)




4 comments

0

line 20 you're firing the remote event before the id is made

0

Well I removed it, I just want the RemoteEvent to work on all scripts. But I don't know how to use it :/

0

Well I removed it, I just want the RemoteEvent to work on all scripts. But I don't know how to use it :/

0

MONIKAMMMMMMMMLOLZEXPLOTIERSA