name: Roblox
description: Avoid common Roblox mistakes — server/client security, DataStore pitfalls, memory leaks, and replication gotchas.
metadata: {"clawdbot":{"emoji":"🎲","os":["linux","darwin","win32"]}}
Server vs Client
Server scripts in ServerScriptService — never trust client data
LocalScripts in StarterPlayerScripts or StarterGui — client-only
RemoteEvent for fire-and-forget — RemoteFunction when server needs to return value
ALWAYS validate on server — client can send anything, exploiters will
Security
Never trust client input — validate everything server-side
Server-side sanity checks — is player allowed? Is value reasonable?
FilteringEnabled is always on — but doesn't protect your RemoteEvents
Don't expose admin commands via RemoteEvents — check permissions server-side
DataStore
:GetAsync()and:SetAsync()can fail — wrap in pcall, retry with backoffRate limits: 60 + numPlayers × 10 requests/minute — queue writes, batch when possible
:UpdateAsync()for read-modify-write — prevents race conditionsSession locking — prevent data loss on rejoin, use
:UpdateAsync()with checkTest with Studio API access enabled — Settings → Security → API Services
Memory Leaks
Connections not disconnected — store and
:Disconnect()when done:Destroy()instances when removed — sets Parent to nil and disconnects eventsPlayer leaving without cleanup —
Players.PlayerRemovingto clean upTables holding references — nil out references you don't need
Character Handling
Character may not exist at PlayerAdded — use
player.CharacterAdded:Wait()or eventCharacter respawns = new character — reconnect events on CharacterAdded
Humanoid.Diedfires on death — for death handling logicLoadCharacter()to force respawn — but prefer natural respawn usually
Replication
ServerStorage: server-only — clients can't see
ReplicatedStorage: both see — shared modules and assets
ReplicatedFirst: loads first on client — loading screens
Workspace replicates to clients — but server is authority
Services Pattern
game:GetService("ServiceName")— don't index directly, fails in different contextsCache service references —
local Players = game:GetService("Players")Common: Players, ReplicatedStorage, ServerStorage, RunService, DataStoreService
RunService
Heartbeatafter physics — most gameplay logicRenderSteppedclient only, before render — camera, visual updatesSteppedbefore physics — physics manipulationAvoid heavy computation every frame — spread over multiple frames
Common Mistakes
wait()deprecated — usetask.wait()for reliable timingspawn()deprecated — usetask.spawn()ortask.defer()Module require returns cached — same table across requires, changes shared
:Clone()doesn't fire events — manually fire if neededPart collisions with CanCollide false — still fire Touched, use CanTouch