Ad
Log in to vote
0

Local script not changing the player's textbox?

Asked by 14 days ago

for information, ive been having a problem. a script i have to cast a definition to a textbox is not working for me. the script is below, and below that is some more information and where some things you'd ask for are located:

local Player = game.Players.LocalPlayer
local f = Player.PlayerGui.Inventory
local UIS = game:GetService("UserInputService")
local R = game:GetService("ReplicatedStorage")
local TL = f.Deskbox.nam.Text
local TL2 = f.Deskbox.Definition.Text
local fhg = function()
        local mouse = game.Players.LocalPlayer:GetMouse()
        local Guis = Player.PlayerGui:GetGuiObjectsAtPosition(mouse.X, mouse.Y)
        if #Guis > 0 then
            for _, Gui in pairs(Guis) do
                if Gui:isA("ImageButton") and Gui.Parent.Parent == f then
                    local String = string.sub(Gui.Name, 2)
                if String == "SLOT" then
                    local St = Gui:FindFirstChild("Type")
                    TL = St.Value
                    local Definition = Gui:FindFirstChild("Definition")
                    TL2 = Definition.Value
                    print(TL2)
                end 
            end 
        end
    else
    end
end

the function fhg is on a constant loop, so it will repeat over and over until the code for some reason breaks (understandable, people probably find a really messy script here, please note im not that good at coding!!!) i changed a bit of routes so its more understandable, but the script is trying to get a certain type of textbox. i could just tag the textboxes, which ill probably actually do once this is resolved, if it does. once it gets the textbox (line 12) it gets "TYPE" which is basically the ui's code. but then, whenever i cast it to the textbox's text, it just doesnt seem to work. same for definition. the prints print the type and definition perfectly fine, but it just seems to not want to work. no errors or anything. i tried making exessive values to see if that'd help, but it didnt. not sure why i tried, anyways someone please help, im begging here!

0
if you have any questions on this, ill probably respond back. Partykidcrazy 15 — 14d

1 answer

Log in to vote
0
Answered by 11 days ago

I haven't spent time actually going through the scripting, however, I do notice you are missing an end for one of your if statements and you have a rogue else.

I haven't tested this at all and could be so very wrong but I'm pretty sure this is better:

local Player = game.Players.LocalPlayer
local f = Player.PlayerGui.Inventory
local UIS = game:GetService("UserInputService")
local R = game:GetService("ReplicatedStorage")
local TL = f.Deskbox.nam.Text
local TL2 = f.Deskbox.Definition.Text
local fhg = function()
    local mouse = game.Players.LocalPlayer:GetMouse()
    local Guis = Player.PlayerGui:GetGuiObjectsAtPosition(mouse.X, mouse.Y)
    if #Guis > 0 then
        for _, Gui in pairs(Guis) do
            if Gui:isA("ImageButton") and Gui.Parent.Parent == f then
                local String = string.sub(Gui.Name, 2)
            end
            if String == "SLOT" then
                local St = Gui:FindFirstChild("Type")
                TL = St.Value
                local Definition = Gui:FindFirstChild("Definition")
                TL2 = Definition.Value
                print(TL2)
            end 
        end
    end
end)

0
Ah. Ill try it when i get home, thanks for actually taking your time to reply. Yeah, i kept going through the script to change certain things and whatnot.   Partykidcrazy 15 — 9d
Ad

Answer this question