How to detect when text box focus lost and detect if ts a number?

  1. i tried everything but it not worked (its a server sided script btw)?

script:

local rs = game:GetService("ReplicatedStorage")

game:GetService("Players").PlayerAdded:Connect(function(plr)
	local plrgui = plr.PlayerGui
	local settingsF = plrgui:WaitForChild("MainUI").SettingsFrame
	local cloneExample = script.Example:Clone()
	cloneExample.Parent = rs:WaitForChild("plrSettings")
	local blood = cloneExample:WaitForChild("BloodEnabled")
	local text= settingsF.bloodSpawn
	
	text.FocusLost:Connect(function(enter)
		if enter == true then
			local ting = tonumber(text.Text)
			if ting then 
				cloneExample.BloodSpawn = text.Text
				if cloneExample.BloodSpawn > 500 then
					cloneExample.BloodSpawn = 500
				end
			end
		end
	end)
	
	cloneExample.Name = plr.Name
	settingsF.BloodSetButton.MouseButton1Click:Connect(function()
		if cloneExample:WaitForChild("BloodEnabled").Value == false then
			blood.Value = true
		else
			blood.Value = false
		end
	end)
end)
1 Like

Ok so first off this should be on the local side.

Second.
What do you mean by this?

Do you want to tell if the once they are done typing in the textbox if what they typed in is a number?
Or something else?
A little context would help

this part of the script not working

yes i want that

Ok first off.

remove:

if enter == true then

with

if enter then

This will only run enter is true, a simpler way to do it.


Any errors at all?

1 Like

nope there are no errors and lemme try hat

nope it not worked and no errors at all

output

 19:13:27.046  Bloody & War @ 08 May 2023 19:13 auto-recovery file was created  -  Studio
  19:13:28.250  TbeyazT committed a new version of script ServerScriptService.VALUEhandler  -  Studio
  19:13:31.170  :: Adonis :: Loading...  -  Server
  19:13:31.172  :: Adonis :: Requiring Adonis MainModule; Model URL: https://www.roblox.com/library/7510592873  -  Studio
  19:13:31.173  Requiring asset 7510592873.
Callstack:
Workspace.Adonis_Loader.Loader., line 156
  -  Studio
  19:13:33.249  loadstring() is not available  -  Server
  19:13:33.249  Stack Begin  -  Studio
  19:13:33.249  
  19:13:33.249  Stack End  -  Studio
  19:13:33.474  SetPartCollisionGroup is deprecated, please use BasePart.CollisionGroup instead. More info: https://devforum.roblox.com/t/updates-to-collision-groups/1990215  -  Studio
  19:13:33.841   ▶ Something unexpectedly tried to set the parent of TbeyazT to chars while trying to set the parent of TbeyazT. Current parent is Workspace. (x2)  -  Studio
  19:13:37.098  :: Adonis :: Place is missing ChatService; Vanilla Roblox chat related features may not work  -  Server
  19:13:38.284  LArm is not a valid member of ReplicatedStorage "ReplicatedStorage"  -  Client - VM:87
  19:13:38.284  Stack Begin  -  Studio
  19:13:38.285  Script 'Players.TbeyazT.PlayerGui.VM', Line 87  -  Studio - VM:87
  19:13:38.285  Stack End  -  Studio
  19:13:39.651  loadstring() is not available  -  Client
  19:13:39.651  Stack Begin  -  Studio
  19:13:39.651 
  19:13:39.651  Stack End  -  Studio
  19:13:39.694  :: Adonis :: Requiring Alerts Module by ID; Expand for module URL >   ▶ {...}  -  Server
  19:13:39.695  Requiring asset 8096250407.
Callstack:
required_asset_7510592873.MainModule.Server.Server, line 387 - require
required_asset_7510592873.MainModule.Server.Plugins.Urgent_Messages, line 19
  -  Server
  19:13:40.224  :: Adonis :: Loading existing player: TbeyazT  -  Server
  19:13:41.322  :: Adonis :: Loading Complete; Required by 0.04358300648623575.Loader.Loader  -  Server
  19:13:51.681  :: Adonis :: Beginning Adonis cleanup & shutdown process...  -  Server
  19:13:51.682  :: Adonis :: Unloading complete  -  Server
  19:13:51.639  Disconnect from ::ffff:127.0.0.1|62941  -  Studio

Are you sure it is not running?
Try putting a print in the If statement to see if it is running,
Cause then we can find where it is not working

1 Like

yes it not prints anything at allll

Try putting a print in the function to see if it is running, cause other wise I have no idea what is wrong with this.

Also where is your script?

text.FocusLost:Connect(function(enter)
print(1)
		if enter == true then
print(2)
			local ting = tonumber(text.Text)
			if ting then 
print(3)
				cloneExample.BloodSpawn = text.Text
				if cloneExample.BloodSpawn > 500 then
					cloneExample.BloodSpawn = 500
				end
			end
		end
	end)

at the server script service so i can change values in server

Ok thats the problem.

Server scripts cant tell if a textbox loses focus.
That can only happen on a client.

1 Like

man its like now i tried to make it fire event
what error i got:

ServerScriptService.VALUEhandler:21: invalid argument #2 (string expected, got Instance)

serverscriptservice =

rs:WaitForChild("Events").valueChange.OnServerEvent:Connect(function(plr,value,newValue)
	rs:WaitForChild("plrSettings"):WaitForChild(plr.Name)[value].Value = newValue
end)

local:

setting.bloodSpawn.FocusLost:Connect(function(enter)
	if enter then
		local ting = tonumber(setting.bloodSpawn.Text)
		if ting then 
			rs:WaitForChild("Events").valueChange:FireServer(rs:WaitForChild("plrSettings"):WaitForChild(plr.Name).BloodSpawn,ting)
		end
	end
end)