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

textbox to change property? how to make it a numbervalue?

so you probably did not understand the question but what I want to do is make a textbox, whatever you put in it is the rate of particles of a particle emmiter except im getting a string value so how do I do this????? ill show you a screenshot and my code

script.Parent.InputChanged:Connect(function()
string = script.Parent.Text
	local hi = tonumber(string)
	hi = game.Workspace.Particle.ParticleEmitter.Rate
	end
end)

oh yeah and if I do this:

script.Parent.InputChanged:Connect(function()
string = script.Parent.Text
for numbers in string.gmatch(string,"%d") do
		print(numbers) 
		game.Workspace.Particle.ParticleEmitter.Rate = numbers
	end
	end)

it can only go up to 9 if I put 10 it will think I put 1 and 0 please help

1 answer

✓ Accepted answer

hey, no one answered me but after lots of work and thinking I found out how to do this

local box = script.Parent
local isPlayerEditing = true

box:GetPropertyChangedSignal("Text"):Connect(function()
	if isPlayerEditing then
		isPlayerEditing = false
		box.Text = string.gsub(box.Text, "%D", "")
		isPlayerEditing = true

end)
script.Parent.InputChanged:Connect(function()
	local t = tonumber(script.Parent.Text)
	game.Workspace.Particle.ParticleEmitter.Rate = t
	game.Workspace.Particle1.ParticleEmitter.Rate = t
	game.Workspace.Particle2.ParticleEmitter.Rate = t
	game.Workspace.Particle3.ParticleEmitter.Rate = t
	game.Workspace.Particle4.ParticleEmitter.Rate = t
	game.Workspace.Particle5.ParticleEmitter.Rate = t
end)

first to use tonumber I need to make sure that the player cant input letters so that is the first thing box.Text = string.gsub

1 comment

0

Good for figuring it out!!

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