I want to have it so that, if the score changes, the player's scoreboard's text will change. I'm getting the error "Unable to cast value to Object". Could it be because the parameter is a player? Still a newbie on FE.
Server Script:
local RepStorage = game:GetService("ReplicatedStorage")
local ChangeScore = RepStorage:WaitForChild("ChangeScore")
local function onChange(player)
ChangeScore:FireClient(player) --errors here
end
script.Parent.Changed:Connect(onChange) --whenever value changes, it'll connect to scoreboard's value
LocalScript:
wait(0.5)
local RepStorage = game:GetService("ReplicatedStorage")
local ChangeScore = RepStorage:WaitForChild("ChangeScore")
local player = game.Players.LocalPlayer
local pgui = player:WaitForChild("PlayerGui")
local board = pgui:WaitForChild("Scoreboard")
local court = player:FindFirstChild("Court")
local modelcourt = workspace:FindFirstChild("1v1Half") -- this is okay in a localscript right?
local home1 = modelcourt:WaitForChild("home")
local function onChange()
if court.Value == 1 then -- i have more than one place where the scoreboard will change
script.Parent.Text = home1.Value -- could be the error idk
else
board.Enabled = false
end
end
ChangeScore.OnClientEvent:Connect(onChange)
Thanks,
LukeGabrieI

7 comments
btw I tried both FireClient and InvokeClient, soooo...
Does the function run?
yeah
the one in server, but it errors after that
So it doesn't send it to the client?
I think the problem is that you don't 'tell' what 'player' is, you can fix that by doing it like this script.Parent.Changed:Connect(function(player) end)
it didnt work gg