Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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.

Ad

Answer this question