maybe something on the remoteevent connection between server value (linearvelocity) and the gui value is wrong, but it wont change the value on the GUI.
server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("UpdateVelocity")
local vehicleSeat = workspace:WaitForChild("traingrupo"):WaitForChild("Model")
:WaitForChild("system"):WaitForChild("VehicleSeat")
local ultimaVelocidad = nil
while true do
local velocidadActual = vehicleSeat.LinearVelocity.LineVelocity
print("Velocidad actual del servidor:", velocidadActual)
if velocidadActual ~= ultimaVelocidad then
print("Enviando velocidad al cliente:", velocidadActual)
remoteEvent:FireAllClients(velocidadActual)
ultimaVelocidad = velocidadActual
end
wait(0.5)
end
client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:FindFirstChild("UpdateVelocity")
if remoteEvent then
print("RemoteEvent 'UpdateVelocity' encontrado correctamente")
else
error("RemoteEvent 'UpdateVelocity' no encontrado en ReplicatedStorage")
end
local textBox = script.Parent
if textBox:IsA("TextBox") then
print("TextBox encontrado:", textBox.Name)
else
error("El LocalScript no está dentro de un TextBox")
end
remoteEvent.OnClientEvent:Connect(function(velocidad)
print("Velocidad recibida del servidor:", velocidad)
if textBox and textBox:IsA("TextBox") then
textBox.Text = tostring(velocidad)
print("TextBox actualizado con:", textBox.Text)
else
print("Error: El TextBox no se puede actualizar")
end
end)
print("El script LocalScript se está ejecutando correctamente.")
the innecesary prints are checks to see if it works: all local checks dont show in output