Hi I'm trying to make it so when "Experience" is changed it sends the value to the client of that changed exp. So in the client a text label might say "Experience: (value)" but when I do it, the client saids the value is nil even though it isn't.
-- OUTPUT ERRORS -- 16:27:39.791 - Unable to cast value to Object 16:27:39.792 - Stack Begin 16:27:39.793 - Script 'ServerScriptService.Script', Line 10
-- Server local d = { level = 12, exp = 15, gold = 0 } local createPopupRequest = game.ReplicatedStorage:WaitForChild("RemoteFunction") local function onPlayerAdded(player) wait(1) createPopupRequest:InvokeClient(d.exp) end game.Players.PlayerAdded:Connect(onPlayerAdded)
-- Client local createPopupRequest = game.ReplicatedStorage:WaitForChild("RemoteFunction") local function onCreatePopupRequested(val) -- it doesn't return a player value a it doesn't need to. script.Parent.TextLabel.Text = "Gold = " .. val end createPopupRequest.OnClientInvoke = onCreatePopupRequested
-- Server local d = { level = 12, exp = 15, gold = 0 } local createPopupRequest = game.ReplicatedStorage:WaitForChild("RemoteFunction") local function onPlayerAdded(player) wait(1) createPopupRequest:InvokeClient(player, d.exp) end game.Players.PlayerAdded:Connect(onPlayerAdded)
--Client local createPopupRequest = game.ReplicatedStorage:WaitForChild("RemoteFunction") local function onCreatePopupRequested(val) script.Parent.TextLabel.Text = "Gold = " .. val end createPopupRequest.OnClientInvoke = onCreatePopupRequested
Let me know how that works. And you should change it to a RemoteEvent.