#Why does SurfaceGui not working?
1 messages · Page 1 of 1 (latest)
my local script in the text button:
script.Parent.MouseButton1Click:Connect(function()
print("Clicked!")
end)
localscripts dont run in workspace
use server script with runcontext set to local
Thanks man! i didnt know it was this easy
** You are now Level 6! **
i stopped my project cuz of this
probably shouldn't recommend newbies do this, they could create problems for themselves later on that are really not obvious to solve
better to use a regular localscript, connect to it by collectionservice or whatever other means, or put the surfacegui in playergui and set the adornee
i prefer the playergui & adornee method
curious, what problems can it cause?
scripts can run more than once in some places
interesting
e.g put one of those runcontext=local scripts into startercharacterscripts and it runs twice
put runcontext=server into backpack/playergui/etc and it runs twice
once from the container, and another from the deployed location
So the containers that get cloned, result in it being ran twice
like starterpack, one copy runs in the starterpack container and the other in the actual player's backpack
so
convenient yeah sure, but generally bad practice coz of that
before considering that having scripts that can execute from anywhere make organizing difficult, because you need to explicitly search out your scripts instead of simply knowing they can only be in certain containers
so, if you know about it and want to use it sure thats fine, but suggesting it to newbies is probably not a good idea because they barely know how to get a script to run, adding these extra problems on top that they aren't expecting is just going to cause more problems later
because there's always going to be someone who thinks, why dont i just make every script a runcontext=local or server script?
Thanks for the idea that sounds better
please don't
or do idk i'm not your dad
what
bad idea
why did u type that then
it has some occasional use but you should avoid it if you can
So even that is not a good idea for surfacegui?
use collectionservice instead or something like that
it has other issues with streaming for example
idk about collectionservice but ill look for some guides ty
if a part has a script in it when it streams it, the script also has to stream in
if you do this all over the place, that's a lot of scripts being downloaded repeatedly
so bad for performance?
maybe roblox has some cache but probably dont want to rely on that
similar issue to cloning scripts in general
anyway
yea i dont want my game to lag or taking forever to open
you can do whatever but if you do want to make all scripts out of runcontext=local then proceed in the full knowledge that it's a fairly stupid idea