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.
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)
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.
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)
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
–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)