Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
wswswff 39
1 year ago

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

Log in to vote
1
Answered by
wswswff 39
1 year ago

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

0
Good for figuring it out!! theking66hayday 841 — 1y
Ad

Answer this question