Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Localscript not changing value of my stringvalue/Localscripts can't change values?

Working on a system where you can look up players in a panel and kick them through the panel. In this part of the panel, I'm storing the user's name in a stringValue to keep for another script that shows the player's backpack. Somehow, the stringValue's value is not changing. Any help on this would be appreciated.

local textbox = script.Parent
local selected = textbox.Parent.Selected
local plrs = game:GetService("Players")
local usernameValue = script.Parent.Parent.Username 

selected.Text = ""
textbox.Text = ""

textbox:GetPropertyChangedSignal("Text"):Connect(function()
	if string.len(textbox.Text) > 20 then
		textbox.Text = string.sub(textbox.Text,1,20)
	end
	selected.Text = ""
	if string.len(textbox.Text) > 0 then
		for _, v in pairs(plrs:GetPlayers()) do
			if string.lower(textbox.Text) == string.sub(string.lower(v.Name),1,string.len(textbox.Text)) then
				selected.Text = v.Name
				usernameValue.Value = v.Name --right here is the part that is somehow not working/help?
				print(v.Name) --just to debug/to lazy to take it out lol
				
			end
		end
	end
end)

2 comments

0

Panel count from this question: 3

0

Called filtering enabled ;)

1 answer

✓ Accepted answer

You can change values via localscript, however it is not recommended because the value will not be replicated to the server. To the server, the value won't change.

3 comments

0

How would I change this value through a localscript? Would I swap it with remoteEvents with a non localScript watching for it to be fired?

0

Yes, use remote events, just don't forget to add security checks on server

0

Alright! Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.