I really don't know why does this script don't changes the String Value in Workspace. Here is the script, if you have any suggestions about this question make sure to leave a comment down there, you are going to help me a lot, and if you help me, I am going to accept your answer!
Script:
local Database = game.Workspace.Level_Database local UsernameValue = Database.Username local UsernameBox = script.Parent local ScreenGui = script.Parent.Parent.Parent function onClicked() UsernameBox.Text = UsernameValue.Value wait(0.1) ScreenGui.Enabled = false end script.Parent.MouseButton1Click:connect(onClicked)
Hey there.
As others have mentioned, you cannot communicate between the client and server directly with FilteringEnabled turned on.
To get past this, you should use a RemoteEvent
sending information from the LocalScript to a Script.
Here is some example code, but check out the links at the bottom of my answer for more in-depth learning.
Client:
local rep = game:GetService("ReplicatedStorage") local sendName = rep:WaitForChild("SendName") --Place a "RemoteEvent" in ReplicatedStorage called "SendName" local usernameBox = script.Parent local screenGui = usernameBox.Parent.Parent function click() screenGui.Enabled = false sendName:FireServer(usernameBox.Text) end usernameBox.MouseButton1Click:Connect(click)
Server:
local rep = game:GetService("ReplicatedStorage") local sendName = rep:WaitForChild("SendName") local database = game.Workspce.Level_Database local usernameVal = Database.Username sendName.OnServerEvent:Connect(function(player, text) usernameVal.Value = text end)
I believe your problem lies in the fact that you're attempting to enable a ScreenGui using a server script. With FE on, you can not modify ScreenGuis with server scripts. Try copying your code into a local script.
Also, I would just like to suggest that you use :Connect()
rather than :connect()
, as it is deprecated.