I'm somewhat alright at Lua but I've only learned bits and pieces of what I need to code some transportation vehicles inside of Roblox.

I'm trying to get a GUI interface of a subway model spawn to open without complicated events or code. With this simplified method, I can only return the specific username with a String. I need to recall the specific username so that GUI can return to that specific user since at the moment without it, the GUI would be sent to a random client, which is not what I want. What I want is the GUI to popup only to the user that stepped on the brick.

However because of the way Lua works, I can't smack a variable in the middle of an object statement as substitution like Java.

What I mean by this is I can declare a variable like local username = hit.Parent to which that value there can be substituted in the statement below cloneGUI.Parent = game.Players.username.PlayerGui

I have tried using Strings to formulate one whole statement, but then it considers Object statements seperate from Strings... I have also tried using the original hit.Parent, but that doesn't work because I'm only referring to the user's body, not their client. Is there a way I can somehow get this to work?

a = script.Parent

script.Parent.SurfaceGui.name.Visible = true

        if (hit.Parent:FindFirstChild("Humanoid")) and (enabled == true) then

            local username = hit.Parent

            print("plr: ", plr)
            print("hit: ", hit)
            print("user: ", username)

            local cloneGUI = game.ServerStorage.PurchaseGUI:clone()
            enabled = false

            cloneGUI.Parent = game.Players.username.PlayerGui

            script.Parent.BrickColor = BrickColor.new(26)--Black

            script.Parent.SurfaceGui.name.Visible = false
            script.Parent.SurfaceGui.countdown.Visible = true
            for i = 30, 1, -1 do
                script.Parent.SurfaceGui.countdown.Text = i
            --Visible Text Again
            script.Parent.SurfaceGui.name.Visible = true
            script.Parent.SurfaceGui.countdown.Visible = false


            script.Parent.BrickColor = BrickColor.new(104) --Purple

            enabled = true


When I reread this post, it seems a bit cryptic. If anything needs to be cleared, I can reply.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.