I’m making a Mario Kart type game, and I just finished programming the cars, but now I’m trying to make them spawn after an intermission, so a new race can start.
I have a folder in the workspace called ‘Stats’ and in it a bool value named “Race” and a number value named “Intermission”.
Unfortunately, GetPropertyChangedSignal() and Changed() only seem to work on the client.
Hopefully, this screenshot has enough information:
Whenever GetPropertyChangedSignal or Changed is called, the script prints “Changed in the client” (or server, depending on which type of script). As seen in the Output, it is only recieved by the client. The number in the top center of the screen is the intermission time, which uses a server script and the intermission value to count down. The script in the workspace is a test script to check if it’s working on the server. No important code there.
I’ve looked on the Developer Hub, although it doesn’t say anything about firing only on clients. I’ve looked at other posts on the forum and only seen problems about Changed() not working when changed on the client. I am very confused because I’ve used GetPropertyChangedSignal before in server scripts.
Notes:
At first, I had the stats in Replicated Storage. I switched to workspace because obviously, that did not work.
I do not want to use Remote Events or Remote Functions because I want it to receive on both sides.
I’ve tried both Value:GetPropertyChangedSignal and Value.Changed although neither of them seem to work in the server.
I’ve tested in both Play Solo and Local Servers but I have the same problem.
The value is changed from the server, not the client.
Maybe I’m not understanding this correctly, but the server won’t recognize any changes made from the client. The client can pick up the changes because they are the one who changed it, but because it isn’t replicated, the server doesn’t see anything changing.
So what you’re saying is that you have two scripts [client / server] that has to detect a change in a value [in the player? or where ever], but it seems to be only detecting change, on the client?
Edit: Misread, it’s not in the player it’s just in the workspace? I know you said it doesn’t work in ReplicatedStorage but that is your best bet to be honest.
Server script in ServerScriptService which counts down the intermission value.
repeat wait() until game:IsLoaded()
local int = workspace.Stats.Intermission
local race = workspace.Stats.Race
int:GetPropertyChangedSignal("Value"):connect(function()
print("Changed in Server")
local val = int.Value
if val > 0 then
wait(1)
race.Value = false
int.Value = val - 1
else
race.Value = true
end
end)
int.Value = 10
Client script, which sets the intermission Gui to the time left in the intermission value.
local int = workspace.Stats.Intermission
int.Changed:connect(function(val)
print("Changed in client")
script.Parent.Text = val
if val > 0 then
script.Parent.Parent.Enabled = true
else
script.Parent.Parent.Enabled = false
end
end)
I think I’ve said somewhere that I had tried both getPropertyChangedSignal and Changed. What you see there is just how it ended up when I gave up trying by myself.
So, my problem is that neither getPropertyChangedSignalorChanged are working in the Server Scripts.
I would restructure how you are doing this or you are going to give yourself a massive headache in the long run.
Have one script – let’s call it Main – that houses essentially the “game clock” and also tells other scripts when to do stuff (idk spawn cars or load maps).
Structured something like this:
Code
BindableTimeEvent = game.ServerStorage.Bindables.TimeChanged
RemoteTimeEvent = game.ReplicatedStorage.Remotes.TimeChanged
-- Time functionos
T = 0
function postTime()
RemoteTimeEvent:FireAllClients(T) -- Notify clients
BindableTimeEvent:Fire(T) -- Notify server scripts
end
function setTime(t)
T = t
postTime()
end
function countDown(l)
for i = 0,l do
setTime(l-i)
wait(1)
end
end
--
function setStatus(str)
-- use another remote function/event here
print(str)
end
function spawnCars()
-- Call a bindable function or something
end
--Main loop
while true do
--Intermission
setStatus('Intermission')
countdown(15)
setStatus('Setting up')
spawnCars()
setStatus("Get ready...")
countdown(3)
-- startRace() -- or whatever
end
Using remote events functions will serve you better in the long run - you don’t have a legitimente reason not to use them. If you need another script to “see” the gameclock for whatever reason use a bindable event. But in all honesty, no other script should really need to anyhow. The Main script should be “calling all the shots” so to speak, ay?
Yeah, that’s probably the best solution I’m going to get. Luckily, I have two problems I’m trying to work out in this game, including this one and I still haven’t gotten a headache yet
I was hoping not to have to use a single server script for this, because of the way I like to organize my games. Although, I do not see any way this solution would go along fine.