#stupid issue with screengui showing linearvelocity value

74 messages · Page 1 of 1 (latest)

supple coral
#

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

vague dew
#

in line velocity a number

supple coral
#

?

#

if its a num? yes

#

can be decimal like 15.2

#

therefore the rounding

vague dew
#

is it 0 on the server always

#

when it prints

supple coral
#

nope

#

its the value it is

vague dew
#

?

supple coral
#

like when the linevelocity goes up and down the print accords to it

#

on server s ide output

#

but it doesnt arrive t o client

vague dew
#

does it print on the client or server tht its firing

supple coral
#

only server

#

no prints from client

vague dew
#

are we 100% sure the client script is running, how many times is that remote firing on the server, and is it the same remote 100%

supple coral
#

how can i check that

#

i put a print on start of script of local and nothing in output lol

vague dew
#

might be da issue

#

where is the local script located

supple coral
#

inside the textbox inside the screengui inside the part inside the model inside workspace

vague dew
#

u just answered ur own question lmao

supple coral
#

:V

vague dew
#

its in workspace

#

and not in the player character

supple coral
#

yeah needs starter

vague dew
#

so it wont run

supple coral
#

ah yes

#

why do they make it so complicated tho

vague dew
#

classic mistake lmaooo

#

no idea

supple coral
#

thank you, ill try

#

Put the surfacegui in Startergui, and adornee to the part, I told chatGPT to adjust the code (i was lazy), this is it, but i have no changes on the GUI..

#

@vague dew if you can help plz

vague dew
#

well uh

#

yk u can just edit the surface gui on the server right

#

in the server script in the car

#

itll just replicate for everyone too

supple coral
#

yeah thats better

vague dew
#

probably less preformant but ur not skilled enough to use tagging n stuff yet

#

so its probably the best optio

supple coral
#

yeah if its simpler better

#

so surfacegui can. be back to the part in worksapce?

abstract meteor
#

collectionservice is pretty easy to use

abstract meteor
supple coral
#

imma do the server side thing

abstract meteor
#

playergui not startergui

supple coral
#

ah

abstract meteor
#

startergui gets copied to new players and on respawn. playergui is what is actually showing. localscripts can run in there

#

technically you can make localscripts that run in workspace but it's not a good or common practice

#

basically make a regular script and change the runcontext to client, then you don't need to make any other changes and what you already have will work the way you expected

supple coral
#

ahh

abstract meteor
#

just don't make it a habit of doing that

supple coral
#

thank you.

#

when you say playergui, do you refeer to startarplayerscripts and inside there?

abstract meteor
#

no

#

Player.PlayerGui

#

starterplayerscripts goes into Player.PlayerScripts and is only visible to the client

#

any localscripts in PlayerGui and PlayerScripts will execute on client.

supple coral
#

i need to place there the surfacegui right

#

with the textbox and localscript

abstract meteor
#

the surfacegui can go either playergui or workspace

supple coral
#

im sorry, but where is playergui, i cannot find it.

abstract meteor
#

it gets created for players automatically. hit run and then look at whats under the players in the explorer.

supple coral
#

but then, how can I put the surfacegui there?

abstract meteor
#

well that depends

#

tbh caleb's solution of just changing the gui on the server is probably the easiest for you

#

there's no reason why you are detouring through the client to update this surfacegui (and thus any changes would only show to that specific client) when you could just do it on the server and it will show for everyone (including players who join after it was changed)

supple coral
#

yeah, better.

#

Perfect, works