Why isnt remote event being received when it should?

so i have this local script in a tool that fires a remote event on the requirements, and idk why but the server never receives it. am i missing something?:

Local:

local tool = script.Parent

tool.Equipped:Connect(function()
	local char = tool.Parent
	local humanoid = char:FindFirstChildOfClass("Humanoid")
	
	task.wait(0.05)

	if humanoid then
		-- Unequip the tool instantly on the server
		if char.DoingMove.Value == false and char.Stun.Value == false then
			game.ReplicatedStorage.Moves.Hammerhead["Hammer Smash"]:FireServer()
			print("move")
		end
		humanoid:UnequipTools()
	end
end)

Server:

local rockmodule = require(game.ServerScriptService:WaitForChild(“RockModule [Fixed]”))

game.ReplicatedStorage:WaitForChild(“Moves”):WaitForChild(“Hammerhead”):WaitForChild(“Hammer Smash”).OnServerEvent:Connect(function(player)
print(“wow”)
local char = player.Character
local humanoid = char:FindFirstChildOfClass(“Humanoid”)
local anim = script:FindFirstChild(“Animation”)

if humanoid and anim and humanoid.Health > 1 and char.DoingMove == false and char.Stun.Value == false then
	char.Stun.Value = true
	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0
	char.DoingMove.Value = true
	local track = humanoid:LoadAnimation(anim)
	track:Play()
	local rootPart = char:FindFirstChild("HumanoidRootPart")

	task.delay(1, function()
		rockmodule.OnGround(rootPart.CFrame * CFrame.new(0, 0, -2), 5, true )
		char.Stun.Value = false
		char.DoingMove.Value = false
		humanoid.WalkSpeed = 16
		humanoid.JumpPower = 50
	end)
end

end)

1 Like

Do not use WaitForChild on the server, it’s bad practice. Also see if the remote event actually ends up firing or not.

It is also highly recommended to play animations on the client, they can automatically replicate.

in the server i put a print for wow, but it doesnt print wow, only “move” from client

1 Like

Add a print above the actual function to see if the script is running or not.

These might be a bit dumb troubleshooting options but that’s how I do it and I get the solution always.

1 Like

wait a minute, if i remove the require module it works but then i need it to make rock craters for a smash, um how would i require it better

1 Like

As expected. You need to see if the module has some delay in it or not. You can also use task.spawn like so:

local rockmodule
task.spawn(function()
	rockmodule = require(game.ServerScriptService:WaitForChild(“RockModule [Fixed]”))
end)

works but when i use a function from module, it says attempt to index nil which im pretty sure means rockmodule isnt defined

I see, then maybe check if there are any delay in said module? Can you show me the modules code?

its 300 lines long… should i just send the OnGround function part of it

That’s… reassuring.

You can see if it has some delay yourself, like check for any wait’s. Do that by pressing Ctrl+H and typing “wait”. This would show every and ANY possible delay.

where would i “type” wait… comand bar?

No.

oh that, ye i mean there are waits but they’re neccessary, i think

If they are unnecessary then remove them?

Can you just send me the code? I can fix the issue better that way.

the module? the onground part or full thing if module

Full thing.

how did u bypass text limit?? anyways

local Debris = workspace:WaitForChild("Debris")
local TweenService = game:GetService("TweenService")

local rockModule = {}

function rockModule.OnGround(Position : CFrame, Size : number, Effects : boolean)
	local Orientation = 0
	local TimeToWait = 5
	local TotalNumberOfRocks = 3
	local ExtraOrientation = 25

	if Size <= 4 then
		TotalNumberOfRocks = math.random(7,8)
	elseif Size < 6 then
		TotalNumberOfRocks = math.random(7,10)
	elseif Size < 12  then
		TotalNumberOfRocks = math.random(9,11)
	else
		TotalNumberOfRocks = math.random(6,7)
	end

	for i = 1, TotalNumberOfRocks do
		local RoomBetweenRocks = Size
		local cframe = Position * CFrame.fromEulerAnglesXYZ(0,math.rad(Orientation),0) * CFrame.new(RoomBetweenRocks,0,RoomBetweenRocks)
		local CFramePosition = cframe.Position

		local NewPart = Instance.new("Part")
		NewPart.Anchored = true
		NewPart.Name = "Rock"
		NewPart.CanCollide = true
		NewPart.Transparency = 0
		NewPart.Parent = workspace.Debris
		NewPart.Shape = Enum.PartType.Block

		if math.random(1,3) == 5 then
			NewPart.Shape = "Wedge"
		end

		NewPart.CFrame = cframe
		NewPart.CFrame = CFrame.lookAt(Vector3.new(CFramePosition.X,0,CFramePosition.Z), Vector3.new(Position.Position.X,0,Position.Position.Z))

		local Params = RaycastParams.new()
		Params.FilterType = Enum.RaycastFilterType.Exclude
		Params.FilterDescendantsInstances = {NewPart,Debris}
		Params.IgnoreWater = true

		local NewRay = workspace:Raycast(CFramePosition+Vector3.new(0,500,0),Vector3.new(0,-1000,0),Params)

		if NewRay and NewRay.Instance then
			NewPart.Material = NewRay.Instance.Material
			NewPart.Color = NewRay.Instance.Color
			NewPart.Transparency = NewRay.Instance.Transparency
		end

		local TotalNewOrientation = Vector3.new(-math.random(ExtraOrientation-10,ExtraOrientation+10),0,0)

		if NewPart.Shape == Enum.PartType.Wedge then
			TotalNewOrientation = TotalNewOrientation + Vector3.new(0,180,0)
		end

		NewPart.Orientation += TotalNewOrientation

		local NewSize = Vector3.new(math.random(math.round(Size*0.7),math.round(Size*1.5)),1,math.random(Size*0.5,Size*1.5))
		NewPart.Size = NewSize + Vector3.new(0,Size*1.5,0)
		NewPart.CFrame = NewPart.CFrame * CFrame.new(0,(NewSize.Y - NewPart.Size.Y)/2,0)

		Orientation += 360 / TotalNumberOfRocks

		task.spawn(function()
			task.wait(math.random(TimeToWait-1, TimeToWait+5))

			local info = TweenInfo.new(4,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
			local Tween = TweenService:Create(NewPart,info,{Position = NewPart.Position - Vector3.new(0,NewPart.Size.Y,0)})
			Tween:Play()

			task.wait(0.5)

			NewPart:Destroy()
		end)
	end

	if Effects == true then
		local function flightPart(PartFlinging)
			local initialHeight = 8 
			local velocitySpread = 32 
			local upwardForce = 22

			local velocity = Vector3.new(
				math.random(-velocitySpread, velocitySpread),
				upwardForce,
				math.random(-velocitySpread, velocitySpread)
			)

			local bodyVelocity = Instance.new("BodyVelocity")
			bodyVelocity.Velocity = velocity
			bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			bodyVelocity.P = 5000
			bodyVelocity.Parent = PartFlinging

			task.wait(0.25)

			bodyVelocity:Destroy()
		end

		local function DestroyingPart(PartToDestroy)
			task.wait(math.random(4,7))
			local multiplier = 0.25

			local NewInfo = TweenInfo.new(1.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
			local PartTween = TweenService:Create(PartToDestroy,NewInfo,{Transparency = 1,Size = Vector3.new(PartToDestroy.Size.X*multiplier,PartToDestroy.Size.Y*multiplier,PartToDestroy.Size.Z*multiplier)})
			PartTween:Play()

			task.wait(1.5)

			PartToDestroy:Destroy()
		end

		local function CreateCube(AnotherSize,Amount)
			for i=1, Amount do
				task.spawn(function()
					local NewCube = Instance.new("Part")
					NewCube.Anchored = false
					NewCube.CanCollide = true
					NewCube.Name = "ThrowingRock"
					NewCube.Shape = Enum.PartType.Block
					NewCube.Parent = Debris
					NewCube.Transparency = 0
					NewCube.Size = AnotherSize
					NewCube.Position = Position.Position

					local Params = RaycastParams.new()
					Params.FilterType = Enum.RaycastFilterType.Exclude
					Params.FilterDescendantsInstances = {NewCube,Debris}
					Params.IgnoreWater = true

					local NewRay = workspace:Raycast(Position.Position+Vector3.new(0,500,0),Vector3.new(0,-1000,0),Params)

					if NewRay and NewRay.Instance then
						NewCube.Material = NewRay.Instance.Material
						NewCube.Color = NewRay.Instance.Color
						NewCube.Transparency = NewRay.Instance.Transparency
					end

					flightPart(NewCube)
					DestroyingPart(NewCube)
				end)
			end
		end

		local TotalBigCubes = CreateCube(Vector3.new(3,3,3),math.random(2,3))
		local TotalSmallCubes = CreateCube(Vector3.new(0.5,0.5,0.5),math.random(4,7))
		local TotalPlates = CreateCube(Vector3.new(4,0.5,2),math.random(2,3))
	end
end

function rockModule.TableFlip(Part : BasePart)
	local upwardForce = 190

	local function flightPart(PartFlinging)
		local initialHeight = 9 
		local velocitySpread = 3

		local velocity = Vector3.new(
			math.random(-velocitySpread, velocitySpread),
			upwardForce,
			math.random(-velocitySpread, velocitySpread)
		)

		local bodyVelocity = Instance.new("BodyVelocity")
		bodyVelocity.Velocity = velocity
		bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		bodyVelocity.P = 5000
		bodyVelocity.Parent = PartFlinging

		task.wait(0.8)

		bodyVelocity:Destroy()
	end

	local function CreateCube(AnotherSize,Amount,position)
		for i=1, Amount do
			task.wait(0.25)

			task.spawn(function()
				local NewCube = Instance.new("Part")
				NewCube.Anchored = false
				NewCube.CanCollide = false
				NewCube.Shape = Enum.PartType.Block
				NewCube.Parent = Debris
				NewCube.Name = "TableFlip Part"
				NewCube.Size = AnotherSize
				NewCube.Position = position.Position
				NewCube.Orientation = Vector3.new(math.random(0,360),math.random(0,360),math.random(0,360))

				local Params = RaycastParams.new()
				Params.FilterType = Enum.RaycastFilterType.Exclude
				Params.FilterDescendantsInstances = {NewCube,Part,Debris}
				Params.IgnoreWater = true

				local NewRay = workspace:Raycast(position.Position+Vector3.new(0,500,0),Vector3.new(0,-1000,0),Params)

				if NewRay and NewRay.Instance then
					NewCube.Material = NewRay.Instance.Material
					NewCube.Color = NewRay.Instance.Color
					NewCube.Transparency = NewRay.Instance.Transparency
				end

				flightPart(NewCube)

				task.wait(10)

				NewCube:Destroy()
			end)
		end
	end

	local OldCFrames = {}
	local SortedCFrames = {}
	local grid = 12
	local TotalSmokeParts

	local startPosition = Part.Position - Vector3.new(Part.Size.X / 2, 0, Part.Size.Z / 2)

	for X = 1,(Part.Size.X) do
		if X % grid == 0 then
			for Z = 1,(Part.Size.Z) do
				if Z % grid == 0 then
					table.insert(OldCFrames, CFrame.new(startPosition + Vector3.new(X, 0, Z)))
				end
			end
		end
	end

	for i=1, #OldCFrames do
		local BestCFrame = nil
		local BestDistance = 10000000

		for b, newCFrame in ipairs(OldCFrames) do
			local Distance = (startPosition - newCFrame.Position).Magnitude

			if Distance < BestDistance then
				BestDistance = Distance
				BestCFrame = newCFrame
			end
		end

		table.insert(SortedCFrames,BestCFrame)
		table.remove(OldCFrames,table.find(OldCFrames,BestCFrame))
	end

	for i=1, #SortedCFrames do
		local cframe = SortedCFrames[i]

		task.spawn(function()
			task.wait((i+100)/100)

			for g=1, 3 do
				task.wait(0.3)

				task.spawn(function()
					local RandomNumber = math.random(1,4)

					if RandomNumber == 1 or RandomNumber == 4 then
						CreateCube(Vector3.new(9,9,9),math.random(1,2),cframe)
					elseif RandomNumber == 2 then
						CreateCube(Vector3.new(6,6,6),math.random(1,2),cframe)
					elseif RandomNumber == 3 then
						CreateCube(Vector3.new(8,2,4),math.random(1,2),cframe)
					end
				end)
			end
		end)
	end
end

function rockModule.Trail(Part : BasePart,Time :number)
	local function CreateCubeUnderPart(Direction)
		local Params = RaycastParams.new()
		Params.FilterType = Enum.RaycastFilterType.Exclude
		Params.FilterDescendantsInstances = {Debris,Part.Parent}
		Params.IgnoreWater = true

		local NewRay = workspace:Raycast(Part.Position+Vector3.new(0,500,0),Vector3.new(0,-1000,0),Params)

		local Y = Part.Position.Y
		local NewCube = Instance.new("Part")		

		if NewRay and NewRay.Instance then
			NewCube.Material = NewRay.Instance.Material
			NewCube.Color = NewRay.Instance.Color
			NewCube.Transparency = NewRay.Instance.Transparency

			Y = NewRay.Instance.Position.Y + NewRay.Instance.Size.Y/2 
		end

		local AnotherPosition = CFrame.new(Part.Position.X,Y,Part.Position.Z)

		if Direction == "Left" then
			AnotherPosition = AnotherPosition * CFrame.new(2,0,0)
		else
			AnotherPosition = AnotherPosition * CFrame.new(-2,0,0)
		end

		NewCube.Anchored = true
		NewCube.CanCollide = true
		NewCube.Name = "TrailRock"
		NewCube.Shape = Enum.PartType.Block
		NewCube.Parent = Debris
		NewCube.Transparency = 0
		NewCube.Size = Vector3.new(0.5,0.5,0.5)
		NewCube.CFrame = AnotherPosition
		NewCube.Orientation = Vector3.new(math.random(1,360),math.random(1,360),math.random(1,360))

		if NewRay and NewRay.Instance then
			NewCube.Material = NewRay.Instance.Material
			NewCube.Color = NewRay.Instance.Color
			NewCube.Transparency = NewRay.Instance.Transparency
		end
	end

	local PerSecond = 4

	for i=1, Time*PerSecond do
		task.wait(0.25)

		CreateCubeUnderPart("Right")
		CreateCubeUnderPart("Left")
	end
end

return rockModule

Secret. x3 (<- Click the link to know.)

Also, about the module. I just tested everything and it works without delays?? I mean, this issue is quite interesting now…

I used this script:

print("starting..")
local m = require(workspace.ModuleScript)
print("ended???")

image

so uh what now

Well, you could just move the position of the rockmodule line, i.e:


game.ReplicatedStorage:WaitForChild(“Moves”):WaitForChild(“Hammerhead”):WaitForChild(“Hammer Smash”).OnServerEvent:Connect(function(player)
print(“wow”)
local char = player.Character
local humanoid = char:FindFirstChildOfClass(“Humanoid”)
local anim = script:FindFirstChild(“Animation”)

if humanoid and anim and humanoid.Health > 1 and char.DoingMove == false and char.Stun.Value == false then
	char.Stun.Value = true
	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0
	char.DoingMove.Value = true
	local track = humanoid:LoadAnimation(anim)
	track:Play()
	local rootPart = char:FindFirstChild("HumanoidRootPart")

	task.delay(1, function()
		rockmodule.OnGround(rootPart.CFrame * CFrame.new(0, 0, -2), 5, true )
		char.Stun.Value = false
		char.DoingMove.Value = false
		humanoid.WalkSpeed = 16
		humanoid.JumpPower = 50
	end)
end
end)
print("Starting to assign the module.")
local rockmodule = require(game.ServerScriptService:WaitForChild(“RockModule [Fixed]”))
print("Assigned the module.")

And also add some prints up and down of it. Just in case.