Remote Event not being fired properly; Script isn't working as intended

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I have 2 scripts that are similar to Jojos Bizzare Adventure; having stands, their attacks can be controlled by typing in the chat a few commands, but there are bugs that i want to fix
  2. What is the issue? Include screenshots / videos if possible!
    LocalScript (placed in StarterPlayerScripts)
local TCS = game:GetService("TextChatService")
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local standEvents = replicatedStorage:WaitForChild("StandEvents")
local mouse = player:GetMouse()

print("Listening for chat commands...")

-- Command dictionary
local chatCommands = {
	["Behold.."] = function() standEvents.SummonStand:FireServer() end,
	["Back down."] = function() standEvents.DesummonStand:FireServer() end,
	["ORA ORA ORAA!!"] = function() standEvents.Barrage:FireServer() end,
	["ORAA!!!"] = function() standEvents.HeavyPunch:FireServer() end,
	["Take this!"] = function() standEvents.ThrowKnife:FireServer(mouse.Hit.Position) end,
	["Ever seen something like this?!"] = function()
		local target = mouse.Target
		if target then
			local targetPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
			if targetPlayer then
				standEvents.HeadSlam:FireServer(targetPlayer)
			end
		end
	end,
	["Forget about time! No one needs time!"] = function() standEvents.TimeStop:FireServer() end,
	["Heh.. Too slow."] = function() standEvents.TimeUnfreeze:FireServer() end,
	["Yo! Come here for a sec?"] = function() standEvents.Pose:FireServer() end
}

local function processChatCommand(properties)
	local message = properties.Text
	print("Processing chat message: " .. message)
	if chatCommands[message] then
		print("Executing command for: " .. message)
		chatCommands[message]()
	else
		print("No command found for message: " .. message)
	end
end

TCS.OnIncomingMessage = processChatCommand

print("Chat command listener hooked.")

The LocalScript does work perfectly; but I don’t think it is firing the Remote Event properly as nothing is being printed despite a print() added in the Script which is below
Script (placed in ServerScriptService)


game.Loaded:Wait()
-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")
local playersService = game:GetService("Players")
local standEvents = replicatedStorage:WaitForChild("StandEvents")
local TweenService = game:GetService("TweenService")
local standsFolder = workspace.ActiveStands

local standRig = replicatedStorage["Stand"] 
repeat task.wait() until standRig
print("FoundStandRig")
repeat task.wait() until standsFolder
print("FoundStandFolder")
local playerStands = {}

local originalSpeeds = {}


local function createTween(part, targetCFrame, duration, easingStyle, easingDirection)
	print("CreatedTween")
	local tweenInfo = TweenInfo.new(duration, easingStyle, easingDirection)
	local tweenGoal = {CFrame = targetCFrame}
	local tween = TweenService:Create(part, tweenInfo, tweenGoal)
	tween:Play()
	return tween
end


local function tweenTransparency(part, targetTransparency, duration)
	print("TweenTransparency")
	local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	local tweenGoal = {Transparency = targetTransparency}
	local tween = TweenService:Create(part, tweenInfo, tweenGoal)
	tween:Play()
end
-- Summon the stand
standEvents.SummonStand.OnServerEvent:Connect(function(player)
	print("Received SummonStand event from " .. player.Name)
	if not playerStands[player] then
		print(player.Name .. " is summoning the stand.")
		local success, em = pcall(function()
		standClone = standRig:Clone()
		end)
		if success then
		print('standrig cloned')
		standClone.Parent = standsFolder
		print('standrig parented?')
		standClone:PivotTo(player.Character.HumanoidRootPart.CFrame * CFrame.new(3, 0, -3))
		playerStands[player] = standClone

		-- Summoning animation (fade in and slight movement)
		for _, part in ipairs(standClone:GetChildren()) do
			print("CheckingStandClonesChildren")
			if part:IsA("BasePart") then
				print("PartIsaPartLOL")
				part.Transparency = 1
				createTween(part, part.CFrame, 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
				game:GetService("TweenService"):Create(part, TweenInfo.new(1), {Transparency = 0}):Play()
				print("Animation played")
			end
		end
	else
		print("Stand is already summoned for " .. player.Name)
	end
	end
end)


-- Desummon the Stand
standEvents.DesummonStand.OnServerEvent:Connect(function(player)
	print("DesummonSignalRecieved")
	local stand = playerStands[player]
	if stand then
		print("Found Stand For: " ..player.Name)
		print(player.Name .. " is desummoning their Stand.")
		-- Desummoning animation (fade out)
		for index, part in ipairs(stand:GetChildren()) do
			print(tostring(index), part.Name)
			if part:IsA("BasePart") then
				print("PartIsPart,  Desummoning...")
				tweenTransparency(part, 1, 1)
			end
		end
		wait(1)
		stand:Destroy()
		playerStands[player] = nil
		print("Desummoned")
	else
		print("No stand found for " .. player.Name)
	end
end)

-- Barrage Attack
standEvents.Barrage.OnServerEvent:Connect(function(player)
	print("Recieved Barrage Signal")
	local stand = playerStands[player]
	if stand then
		print("Found Stand")
		print(player.Name .. " is performing a barrage attack.")
		local startPos = stand.PrimaryPart.CFrame
		print("Head being utilized for CFrames animation tweening")
		local barrageDuration = 4
		local punchDuration = 0.2
		local forwardPos = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)
		local barrageTween = createTween(stand.PrimaryPart, forwardPos, barrageDuration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)

		
		for i = 1, 20 do
			createTween(stand.PrimaryPart, forwardPos * CFrame.new(0, 0, -0.5), punchDuration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
			wait(0.2)
			createTween(stand.PrimaryPart, forwardPos * CFrame.new(0, 0, 0.5), punchDuration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
			wait(0.2)
		end

		
		barrageTween.Completed:Wait()
		createTween(stand.PrimaryPart, startPos, 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	else
		print("No stand available for barrage attack.")
	end
end)

-- Heavy Punch Attack
standEvents.HeavyPunch.OnServerEvent:Connect(function(player)
	print('Event recieved')
	local stand = playerStands[player]
	if stand then
		print(player.Name .. " is performing a heavy punch.")
		local startPos = stand.PrimaryPart.CFrame
		local punchPos = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)

		
		createTween(stand.PrimaryPart, punchPos, 0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
		wait(0.5)
		
		createTween(stand.PrimaryPart, startPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	else
		print("No stand available for heavy punch.")
	end
end)

-- Knife Throwing Attack
standEvents.ThrowKnife.OnServerEvent:Connect(function(player, mouseHitPos)
	print('Event recieved')
	local stand = playerStands[player]
	if stand then
		print(player.Name .. " is throwing knives.")
		local startPos = stand.PrimaryPart.CFrame
		local forwardPos = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)

		
		createTween(stand.PrimaryPart, forwardPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
		wait(0.5)

		
		for i = 1, 5 do
			local knife = Instance.new("Part")
			knife.Size = Vector3.new(1, 0.2, 5)
			knife.Shape = Enum.PartType.Block
			knife.Color = Color3.new(0.8, 0.8, 0.8) -- Silver color
			knife.Anchored = false
			knife.CFrame = stand.PrimaryPart.CFrame * CFrame.new(0, 0, -i) -- Create knife behind stand
			knife.Parent = workspace

			
			local bodyVelocity = Instance.new("BodyVelocity", knife)
			bodyVelocity.MaxForce = Vector3.new(1e6, 1e6, 1e6)
			bodyVelocity.Velocity = (mouseHitPos - knife.Position).unit * 100 -- Throw speed
			game.Debris:AddItem(knife, 5) -- Clean up knife after 5 seconds
			print("knife cleaned up")
		end

		
		createTween(stand.PrimaryPart, startPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
		print("knife thrown")
	else
		print("No stand available for knife throw.")
	end
end)

-- Head Slam Logic
standEvents.HeadSlam.OnServerEvent:Connect(function(player, targetPlayer)
	print("HeadSlam event recieved")
	local stand = playerStands[player]
	if stand and targetPlayer then
		print(player.Name .. " is performing a head slam on " .. targetPlayer.Name)

		-- Teleport stand to the target player
		local targetRoot = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
		if targetRoot then
			local standStartPos = stand.PrimaryPart.CFrame
			stand:SetPrimaryPartCFrame(targetRoot.CFrame * CFrame.new(0, 5, 0)) -- Move stand above target

			-- Hold and slam the target player
			wait(0.5)
			targetRoot.Anchored = true -- Freeze target during slam
			local slamPos = targetRoot.CFrame * CFrame.new(0, -5, 0)
			createTween(stand.PrimaryPart, slamPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
			wait(0.5)
			targetRoot.Anchored = false -- Unfreeze target after slam

			-- Return the stand to its original position
			createTween(stand.PrimaryPart, standStartPos, 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
		end
	else
		print("Head Slam failed: No target or no stand available.")
	end
end)

-- Time Stop
standEvents.TimeStop.OnServerEvent:Connect(function(player)
	print(player.Name .. " has stopped time.")
	for _, plr in pairs(playersService:GetPlayers()) do
		if plr.Character then
			local humanoid = plr.Character:FindFirstChild("Humanoid")
			if humanoid then
				originalSpeeds[plr] = {WalkSpeed = humanoid.WalkSpeed, JumpPower = humanoid.JumpPower}
				humanoid.WalkSpeed = 0
				humanoid.JumpPower = 0
			end
		end
	end
end)

-- Time Unfreeze
standEvents.TimeUnfreeze.OnServerEvent:Connect(function(player)
	print(player.Name .. " has unfrozen time.")
	for plr, speedInfo in pairs(originalSpeeds) do
		if plr.Character then
			local humanoid = plr.Character:FindFirstChild("Humanoid")
			if humanoid then
				humanoid.WalkSpeed = speedInfo.WalkSpeed or 16
				humanoid.JumpPower = speedInfo.JumpPower or 50
			end
		end
	end
	originalSpeeds = {} -- Clear the stored speed info
end)

-- Pose Ability
standEvents.Pose.OnServerEvent:Connect(function(player)
	local stand = playerStands[player]
	if stand then
		print(player.Name .. " is posing with the stand.")
		-- Pose animation yet to be added
	end
end)

Nothing prints in here, like absolutely nothing. standRig isn’t being cloned to ActiveStands
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried print statements and they work for the script initialization but not for the chat commands; other hacky ways (like UserInputService) but to no use as they dont work either.
I think it’s probably Remote Events not firing correctly; but ill let you devs decide.

Instead of the old Player.Chatted which uses the roblox legacy chat system use the new TextChatService.SendingMessage.
Use this script as the local script instead.

local TextChatService = game:GetService("TextChatService")
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local standEvents = replicatedStorage:WaitForChild("StandEvents", 5)
local mouse = player:GetMouse()

print("Variables initialized")

-- Command dictionary
local chatCommands = {
	"Behold..", 
	"Back down.",
	"ORA ORA ORAA!!",
	"ORAA!!!",
	"Take this!",
	"Ever seen something like this?!",
	"Forget about time! No one needs time!",
	"Heh.. Too slow.",
	"Yo! Come here for a sec?"
}

local functions = {
	function() standEvents.SummonStand:FireServer() end,
	function() standEvents.DesummonStand:FireServer() end,
	function() standEvents.Barrage:FireServer() end,
	function() standEvents.HeavyPunch:FireServer() end,
	function() standEvents.ThrowKnife:FireServer() end,
	function()
		local target = mouse.Target
		if target then
			local targetPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
			if targetPlayer then
				standEvents.HeadSlam:FireServer(targetPlayer)
			else
				print("No target player found.")
			end
		else
			print("Mouse target is nil.")
		end
	end,
	function() standEvents.TimeStop:FireServer() end,
	function() standEvents.TimeUnfreeze:FireServer() end,
	function() standEvents.Pose:FireServer() end
}

local function processChatCommand(message:TextChatMessage)
	print("Processing chat message: " .. message.Text)
	local authorizedPlayers = {["yesssssssss90900"] = true, ["makboiinthehouse"] = true}
	if authorizedPlayers[player.Name] then
		print("Authorized")
		for i, v in chatCommands do
			if message.Text:lower() == v:lower() then  -- Case-insensitive comparison
				functions[i]()
				return
			end
		end
	else
		print("Unauthorized player: " .. player.Name)
	end
end

TextChatService.SendingMessage:Connect(processChatCommand)

print("LocalScript up and running")

This doesn’t really matter but in the code where you state the authorized players you don’t have to set it to true

local authorizedPlayers = {["yesssssssss90900"] = true, ["makboiinthehouse"] = true}

You can just do this

local authorizedPlayers = {["yesssssssss90900"], ["makboiinthehouse"]}

Because it’ll return nill, if it is not in the data and if found it returns true specifically in an if statment

{ ["key"] } would be an incomplete statement, because the usage of brackets implies that you are going to assign the key X to the value of Y. I assume what you meant was using an array, so:
{"name1", "name2"}
and then table.find(authorizedPlayers, player.Name) ~= nil to check if the name is within it.

1 Like

Thanks so much! Got really confused on there because I didn’t know if my game had the legacy chat system or not; your revised script helps alot; but now I have another problem; it does print “Processing chat message: Behold…” and “Authorized” but it wont do anything else. I believe this is due to the Remote Events not firing properly as they dont seem to print anything even while putting this in: print("Received SummonStand event from " .. player.Name)
I’m a complete noob when it comes to handling Remote Events but it might be due to how I’m handling the functions for each chat commands. Hints or clues would be greatly appreciated!

EDIT: Just decided to rewrite the LocalScript fully and it works but wont fire the Remote Events.

yeah, I just copied and pasted, but you got it right

Bumping this because my problem still isn’t resolved…

2nd Bump. Someone help please, I’m stuck trying to figure out the problem!

Please send a picture of the output window.

I cant send a picture, but there is no prints being received from the script in ServerScriptService.
when I run a command like “Behold…” It prints “Processing chat message: Behold…” and “Executing command for: Behold…” but it doesn’t do anything else. How do I know the Remote Event isn’t being fired? The print statements “SummonStand event triggered” don’t output even when i type in the chat command.

After a ton of debugging, finally found the error and fixed it. Thanks to those who tried to help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.