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

Sending a variable to a client using arguments?

Asked by 5 years ago

I've tried to send a variable using arguments. From Server to Client then it should print variable. The problem is when the script is running,then it's just printing " nil ". But how can I fix this?

My serverside script

local Event = game.ReplicatedStorage.Printy
while true do
    wait(0.0555)
    local X = "hello"
    Event:FireAllClients(X)
end

Clientside:

local Event = game.ReplicatedStorage.Printy

Event.OnClientEvent:Connect(function(player,X)
print(X)
end)

It's always ending up printing " nil ".

0
Np :D Can you upvote and accept as answer pls? superalp1111 662 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

On ServerEvent, you receive a player who fired the RemoteEvent, but on ClientEvent, you do not receive a player. Delete the player parameter for your function, because that's what X is :D

0
Thank you for this reponse. :D bbudder 7 — 5y
0
Np :D Can you upvote and accept as answer pls? superalp1111 662 — 5y
0
He can't upvote yet mixgingengerina10 223 — 5y
0
Don't remind users to accept your answer. It is nature for them to accept it. You're just being greedy. User#19524 175 — 5y
Ad

Answer this question