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

Something is wrong with "FireClient"?

Asked by 8 years ago

The error states that plr must be an object, even though when I print out the player before firing, it says my username. Why is this happening and how can I fix this? P.S. The if statement is inside of a modulescript function and fires every 1 second in a while true do loop.

    if seat:FindFirstChild("SeatWeld") and seat.SeatWeld.Part1.Parent.ClassName == "Model" then
        plr = game.Players:GetPlayerFromCharacter(seat.SeatWeld.Part1.Parent)
        print(plr)
        Sitting = true
        SitEvent:FireClient(plr,Sitting,seat) -- here
    else
        Sitting = nil
        SitEvent:FireClient(plr,Sitting,seat)
    end
0
What line are you getting the issue on? Scootakip 299 — 8y
0
On line 3, try print(type(plr)) and let me know what it prints. Validark 1580 — 8y
0
The script may be jumping to "else," and based on this code, you never provided a definition for 'plr' in this if statement route. I would need to see more context in order to make this an accurate judgement. Does it actually error on line 5? Legojoker 345 — 8y
0
^ User#6546 35 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Servers and Clients

If you are using a server script to :FireClient() and using a server script to use .OnClientEvent, it will not work.

You need to FireClient from servers, and receive ClientEvents from the Client.

Hope this helped.

Ad

Answer this question