String value works on client and not server-side

  1. What is the issue?
    This more has to due with the leaderboard, what’s meant to happen is it’s meant to show what cars everyone has spawned in.

Good news: it shows for the client
Bad news: it doesn’t show for everyone else but themselves.

Apond looking in the server side of thing it seems the reason for this is the fact the values aren’t even appearing inside each players folder and instead is empty.

Server-Side
Server - Roblox Studio 7_27_2022 10_20_49 PM

Client-Side


Do believe that it works, just on how to fix this

Wondering how it works, I have a different script where it gets the text of whatever the vehicle is named off, then fires the RemoteEvent for when you spawn the car in and bam it shows you the name

This script below is a normal script inside of ServerScriptService

local Event = game.ReplicatedStorage.Leaderboard_CarNameEvent

Event.OnServerEvent:Connect(function(player)
	player:FindFirstChild("leaderstats"):FindFirstChild("CurrentCar").Value = game.StarterGui.ScreenGui.Respawn_Car.Spawn_Car_Name.Value-- is there something that needs to be changed here (most likely it's a yes)
end)

Please do not write entire scripts or design entire systems for the person writing this post.

Assuming that you want to change the leaderstat value to the player’s car selected in their gui try this instead of changing it to the startergui’s which would be the default one in the server and not the player itself


local Event = game.ReplicatedStorage.Leaderboard_CarNameEvent

Event.OnServerEvent:Connect(function(player)
	player:FindFirstChild("leaderstats"):FindFirstChild("CurrentCar").Value = player.PlayerGui.ScreenGui.Respawn_Car.Spawn_Car_Name.Value
end)

Here

game.StarterGui.ScreenGui

It should be

player.PlayerGui.ScreenGui

Nope dose nothing and plus both player 1/2 values are empty when looking into their leaderstats

1 Like

This means that the value you are trying to set it as is nil, or changed by the client so the server script wont be able to see it

on the client you can see what car you have spawned in, looking in a different window mode and it shows the value is empty which means it’s empty for all the other players.

mind you that this is a normal script and not a local script.

I mean the other value, is it changed by client?

yep it sure dose apart from only you being able to see the car spawned in, images below


I mean this

player.PlayerGui.ScreenGui.Respawn_Car.Spawn_Car_Name.Value

yeah already tried and didn’t work.

Tried What??? Is it changed by client or server.

the client only it works on. and not the server side.

Exactly, thats why, the value on the server is nil so it wont change leaderstats

do wonder if it might have to due with this maybe (Unless it’s fine)

this is for when you click the spawn button that’s how it works

local Clicked = script.Parent
local player = game.Players.LocalPlayer

Clicked.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Leaderboard_CarNameEvent:FireServer()
end)

if it’s not this than, what’s the more better way for it? (if you have any ideas on it)

You need to use a server script not client(local)

The reason thia happens is because the textbox is still blank in serverside since the client is the one editting make your remote event pass the car name as a parameter

The title says it all; you need to be using a RemoteEvent to send the value from the client to the server to set the value.

But don’t forget that the first parameter is always the player who sent it!

–I can assume this is where the parameter would go somewhere inside this line of code?

local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = ReplicatedStorage:WaitForChild("SpawnCar")
local DeleteCarEvent = ReplicatedStorage:WaitForChild("DeleteCar")
local carName = script.Parent.Spawn_Car_Name
local SpawnCarFrame = script.Parent.Parent
local FaVeNa = player:FindFirstChild("leaderstats"):FindFirstChild("CurrentCar")

script.Parent.MouseButton1Down:Connect(function()
	FaVeNa.Value = script.Parent.Parent.Car_Name.Text
        --I can assume this is where the parameter would go?
	local CurrentCar = game.Workspace:FindFirstChild(player.Name .. 'sCar')
	if not CurrentCar then
		SpawnCarEvent:FireServer(carName.Value)
	else
		if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") then
			player.Character.Humanoid.Sit = false
		end
		wait()
		DeleteCarEvent:FireServer(CurrentCar)
		SpawnCarEvent:FireServer(carName.Value)
	end
end)

What about the server? This looks good.

this is the server one where it’s meant to fire for everyone to see on the leaderboard (it’s stored inside ServerScriptService)

local Event = game.ReplicatedStorage.Leaderboard_CarNameEvent

Event.OnServerEvent:Connect(function(player)
	player:FindFirstChild("leaderstats"):FindFirstChild("CurrentCar").Value = player:FindFirstChild("leaderstats"):FindFirstChild("CurrentCar").Value
end)