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
Local Script
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 home = modelcourt:WaitForChild("home") court.Changed:connect(function() print(court.Value) -- tell me what this prints local courtvalue = court.Value if courtvalue == 1 then ChangeScore:FireServer(true) -- send data to server script that is connected to the 'ChangeScore' remote elseif not courtvalue == 1 then board.Enabled = false end end) ChangeScore.OnClientEvent:connect(function(canchange) if canchange == true then script.Parent.Text = home.Value end end)
Server Script
local RepStorage = game:GetService("ReplicatedStorage") local ChangeScore = RepStorage:WaitForChild("ChangeScore") function ChangeValue(player, canchange) -- receive the data, remember the first parameter is always the player who :FireServer print("" .. player.Name .. " has fired ChangeScore remote!") if canchange then ChangeScore:FireClient(true) end end ChangeScore.OnServerEvent:connect(ChangeValue)