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

FireClient not working and no errors showing up in output?

Hello, I finished writing this only for me to realize I'm not logged in when I clicked ask question so sorry if this seems a bit rushed but I am making 2 moves where when I press Q while having my mouse on the target I would be welded and teleported to them giving the illusion that im controlling them and the second move where when I press e while having my mouse over a target it would swap our positions it was working fine until I wanted to make it so that the victim being controlled wont be able to use moves when he is being controlled so I added a script that would add a bool value and when he gets controlled it would set it to true but when I added that and a few things to my scripts so it would detect if the bool is true or false it wont even work anymore, I put some print commands to see where is when it broke because it wont give any errors and it seems to break at the fire client part I dont really understand fireclient much so if im doing anything wrong with the fire client please let me know --output 1st. Got Passed Local script Controlled verify!, 2nd. Remote Event Call Received!, 3rd. Got passed character verify, 4th. Got passed Controlled Check!, 5th. Called Client Event! -- end of output It would say that it called the client but the client wont respond anything im doing wrong?

script to insert bool value (server script)

wait()
local char = script.Parent
wait()
local controlCheck = Instance.new("BoolValue")
controlCheck.Name = "ControlledCheck"
controlCheck.Value = false
controlCheck.Parent = char
wait(0.5)
script:Destroy()

script to check if player is being controlled only called when he uses a move (server script)

game.ReplicatedStorage.Remotes.Check.CheckControl.OnServerEvent:Connect(function(plr, Remote)
	print("Remote Event Call Received!")
	if plr.Character then
		print("Got passed character verify")
		local ControlledCheck = plr.Character:WaitForChild("ControlledCheck",5)
		if ControlledCheck.Value == false then
			print("Got passed Controlled Check!")
			game.ReplicatedStorage.Remotes.Check.CheckControl:FireClient(plr,false,Remote)
			print("Called Client Event!")
		elseif ControlledCheck.Value == true then
			print("Failed Controlled Event")
			game.ReplicatedStorage.Remotes.Check.CheckControl:FireClient(plr,true,Remote)
			print("Called failed event")
		end
	end
end)

local script for the keycode and firing events

local players = game:GetService("Players")
local plr = players.LocalPlayer
local mouse = plr:GetMouse()
local Controlling = false
local char = plr.Character or plr.CharacterAdded:Wait()
local ControlledCheck = char:WaitForChild("ControlledCheck",60)

--[[mouse.Button1Down:Connect(function()
	local target = mouse.Target
	
	if target ~= nil then
		if Controlling == true then
			Controlling = false
			game.ReplicatedStorage.Remotes.UnControl:FireServer()
		elseif target.Parent:FindFirstChild("Humanoid") ~= nil and Controlling == false then
			Controlling = true
			game.ReplicatedStorage.Remotes.Control:FireServer(target, false, plr.Character.Humanoid.MaxHealth, plr.Character.Humanoid.Health)
		end
	end
end)]] -- previous code that was scratched
--[[
1 = UnControl Event
2 = Control Event
3 = Swap Event
]]
game:GetService("UserInputService").InputBegan:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Q then
		local target = mouse.Target

		if target ~= nil then
			if Controlling == true then
				if ControlledCheck.Value == false then
					print("Got passed local script verify for UnControl")
					game.ReplicatedStorage.Remotes.Check.CheckControl:FireServer(1)
					game.ReplicatedStorage.Remotes.Check.CheckControl.OnClientEvent:Connect(function(Result,Remote) -- prevent person from using moves when being controlled
						if Result == false and Remote == 1 then
							Controlling = false
							print("Executed UnControlling victim remote")
							game.ReplicatedStorage.Remotes.UnControl:FireServer(plr)
							print("Executed uncontrolling victim now")
						end
					end)
				end
			elseif --[[target.Parent:FindFirstChild("Humanoid") ~= nil and ]]Controlling == false then
				if ControlledCheck.Value == false then
					print("Got Passed Local script Controlled verify!")
					game.ReplicatedStorage.Remotes.Check.CheckControl:FireServer(plr, 2)
					game.ReplicatedStorage.Remotes.Check.CheckControl.OnClientEvent:Connect(function(Result,Remote) -- prevent person from using moves when being controlled
						if Result == false and Remote == 2 then
							Controlling = true
							print("Executing control victim remote!")
							game.ReplicatedStorage.Remotes.Control:FireServer(target, false, plr.Character.Humanoid.MaxHealth, plr.Character.Humanoid.Health)
							print("Executed controlling victim now")
						end
					end)
					
				end
			end
		end
	elseif Key.KeyCode == Enum.KeyCode.E then
		local target = mouse.Target
		if target ~= nil then
			print("Got passed ~= nil")
			if target.Parent:FindFirstChild("Humanoid") ~= nil then
				print("Got Passed Humanoid ~= nil")
				if Controlling == true then
					print("Got passed controlling")
					if ControlledCheck.Value == false then
						print("Firing Remote Event")
						game.ReplicatedStorage.Remotes.Check.CheckControl:FireServer(plr,3)
						game.ReplicatedStorage.Remotes.Check.CheckControl.OnClientEvent:Connect(function(Result,Remote) -- prevent person from using moves when being controlled
							if Result == false and Remote == 3 then
								game.ReplicatedStorage.Remotes.Swap:FireServer(plr,target)
							end
						end)
					end
				end
			end
		end
	end
end)

1 answer

✓ Accepted answer

In your local script for keycode, etc line 70 or 47 you are passing 'plr' as an argument and a number as a second argument.

Meanwhile in your server script:

game.ReplicatedStorage.Remotes.Check.CheckControl.OnServerEvent:Connect(function(plr, Remote) 

-- Here your .OnServerEvent received plr as player who fired it and Remote as player who fired it because your local script is trying to fire with :FireServer(plr, 2)

You are trying to receive plr and Remote but on default .OnServerEvent will have player objects as its first argument. So in your .OnServerEvent parameters: plr is the player who fired it and second argument 'Remote' will be the same as the first one because you are firing with 'plr' argument as seen in your local script line 70 or 47

In your server script line 8 or 12 you are passing 3 arguments which is: 'plr', 'boolean value', 'Remote'.

Meanwhile in your local script for keycode line 35 or 48 you are trying to receive 2 arguments which is 'Result' and 'Remote'. Result being a boolean value and Remote being a player. Which doesn't meet the requirement of your if statement

You can remove 'plr' argument in your :FireServer() to fix this and prevent further problems. Sorry for my grammar because I'm not an english speaker. Let me know if it works because I'm not sure if that was the problem without a test

3 comments

0

Hello I have tried your answer and it seemed to have fixed the control script but the swap script is still broken I will try to figure out how to fix that myself tho thank you for your help!

0

Figured out how to fix the swap it was just a line of code that was only meant to be in the control check

0

No problem

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