Scripts performing well/only in Studio

'Ello, newbie here.

Got an issue with scripts in which they perform best in Studio, but delay when playing the game or simply don’t work at all. What might be the reason here? Tryna get the scripts to work at the same speed as they do in Studio. Being a newbie, I’m clueless as to solutions.

The scripts that delay are the ones that change a part’s transparency when it’s touched. Though, each individual part has the script. Maybe I should reduce it to just one script? If so, how might I do this?

The script that doesn’t work relates to GUI buttons. It basically does the same thing, but with clicks and not touches.

The issue here is latency.

Each game has a server and a client. The client is your PC (graphics, LocalScripts, camera, etc.) and the server is the main game.

When you test in Play Solo – or even in a Local Server, for that matter – the server is also hosted on your PC so there is little to no latency.
However, in a proper game, there is travel time between your PC and the server – basically think of it like your internet speeds.

There is really only one solution to your issue, and that is to (at least) do everything visual on your client, then send the actual information (request to change transparency) to the server. It sounds a bit weird, but you should understand what I mean after reading the items in the list below.

See these wiki articles for more info:

* If you want your game to be secure and listed

Yes, you should. Have a control script which listens for touch events changes the transparency on a per part basis. Here’s a crude example:

local parts = game.Workspace:WaitForChild("TouchParts")
for _, part in ipairs(parts) do
   local touchDeb = false
   part.Touched:connect(function()
      if(touchDeb == true) then  return  end
         touchDeb = true
         part.Transparency = 0.5
         wait(1)
         part.Transparency = 0
         touchDeb = false
      end
   end)
end

Is this done locally? If so, you shouldn’t be having any delay on live servers. Otherwise, yes, the server interaction would introduce latency.

Also latency aside, I believe the underlying Lua stuff runs better online since it’s not bogged down with debug stuff (just to clear up any misconception there)

1 Like