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

"RemoteEvent:OnClientEvent" Dose not work!?!?

Script:

local Seat = script.Parent
local PCH = game.ReplicatedStorage:WaitForChild("PlayCamHandler")

Seat.Touched:connect(function(hit)
	if hit:FindFirstChild("Humanoid") then
		PCH:FireAllClients(Seat)
	end
	print("lol")
end)

Local Script:

local Cam = workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local PCH = game.ReplicatedStorage:WaitForChild("PlayCamHandler")

--Cam.CameraType = Enum.CameraType.Custom

local Cam = workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local PCH = game.ReplicatedStorage:WaitForChild("PlayCamHandler")

Cam.CameraType = Enum.CameraType.Custom

PCH.OnClientEvent:Connect(function(Seat)
	local CheckOut = Seat.Parent.Parent
	local Team = Seat.Configuration.Team
	local CamPart = CheckOut.CamParts.CamPart1
	
	print(1)
	
	Seat.Changed:Connect(function()
		print(2)
		local ply
		
		if Seat.Occupant ~= nil then
			ply = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
		else
			ply = nil
		end
		
		print(ply)


		if Player.Team == Team.Value then
			if ply == Player then
				Cam.CameraType = Enum.CameraType.Scriptable
				Cam.CFrame = CamPart.CFrame
				print(3.5)
			elseif ply == nil then
				Cam.CameraType = Enum.CameraType.Custom
				print(4)
			end
		end
	end)
end)

1 answer

✓ Accepted answer

For those looking at this question.

I have been helping in the community chat to debug this.

--server script
local Seat = script.Parent
local PCH = game.ReplicatedStorage:WaitForChild("PlayCamHandler")
Seat.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then -- I originally told you 
hit:FindFirstChild() but thats a mistake on my part. It should be corrected now. 
         PCH:FireAllClients(Seat)
    end

end)

This is what was causing your issues.

You originally needed a function event to consistently fire the "FireAllClients" function. To do so for a quick solution, I recommended this, but I would use something more complex if applicable and would recommend a debounce.

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