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

Issue with client not receiving signal from server when it should?

Asked by
wswswff 39
1 year ago

I'm making a tutorial system. The server detects if the player has joined for the first time. If so, it fires a remote event that is in replicated storage. Here is the server code:

local Users, DataService = game:GetService("Players"), game:GetService("DataStoreService")
local Store = DataService:GetDataStore("IsPlayersNewhWujAwadfghjkws2") -- we make a store storing if they played already or not.

Users.PlayerAdded:Connect(function(User) -- this is when they join!
     -- DataStoreService (DSS) uses keys to store data. Using the player's userid makes all keys unique and won't mess with the code!
    if Store:GetAsync(User.UserId) then

    else
        Store:SetAsync(User.UserId, true)
        local char = User.Character or User.CharacterAdded:Wait()
        print("ok server fshould have fired")
        wait(2)
        game.ReplicatedStorage.StartTutorial:FireClient(User)
        print("i mean client")
    end -- this will stop the code if they already joined the game before!
    -- if this data exists when they next join then it will stop the code. but since it does exist it will then add a value(s) for next time.
end)

I the client does not print while the server doesClient:

local r = game.ReplicatedStorage.StartTutorial
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait() or plr.Character
r.OnClientEvent:Connect(function(e)
    print(e.Name)
    print("client Fired Initiating tutorial")
    local plot = char.Plot.Value
    print(plot.Name)
end)

If you know why please help

0
In the first script does "i mean client" get printed?? 666_brithday 103 — 1y
0
in the client e doesn't exist. OnClientEvent's callback function doesn't have any parameters except if you added more parameters to FireClient other than User. T3_MasterGamer 2189 — 1y

1 answer

Log in to vote
0
Answered by
manith513 121
1 year ago

In the local script, onclientevent does not have a callback or any parameters you are sending. Since the first parameter of fireclient is who you're sending it to, it doesn't send anything else with it. Try doing

FireClient(User, User.Name) 

instead as that will actually give the variable e a definition.

Ad

Answer this question