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

How do you set the name of a frame in a GUI to a variable value?

Asked by 5 years ago

I am creating a Mobile Data Terminal and Computer Aided Dispatch system for an emergency services role-play group. When a unit sets their status, it fires a remote event which in turn fires the dispatched client GUI, updating the status of the units status on the CAD side of things. This is what it should do anyway. I am still working on finishing this aspect however I have hit a hiccup.

When the dispatchers client is fired, a frame is copied into a scrolling frame with a UIGridLayout. The frame which is copied is a blank text label and buttons. I want to be able to copy the frame (which I have successfully done) and then set the name of the frame to the value of a variable that is passed when the client is fired.

Hierarchy

Units GUI which fires server

script.Parent.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.MobileDataTerminal.Status:FireServer(script.Parent.Name, script.Parent.Parent.Parent.Parent.Parent.LocalValues.Service.Value, script.Parent.Parent.Parent.Parent.Parent.LocalValues.Car.Value)
end)

Server handler which in turn fires dispatchers client

game.ReplicatedStorage.MobileDataTerminal.Status.OnServerEvent:Connect(function(player, code, service, car)
    game.ReplicatedStorage.MobileDataTerminal.Status:FireAllClients(code, service, car)
end)

Dispatchers client side script

game.ReplicatedStorage.MobileDataTerminal.Status.OnClientEvent:Connect(function(code, service, car)
    print("Received")
    local frame = script.Parent.Frame:Clone()
    frame.Parent = script.Parent.ScrollingFrame
    frame.Name = car
    frame.TextLabel.Text = car
    frame.Visible = true
end)

The above script successfully clones the frame into the scrolling frame however the line stating frame.Name = car does not set the name of the frame to the value of the variable. The script successfully prints "Received" in chat, however no errors along with it.

It would be appreciated if someone could help me solve this, as I have been working to fix it for a while now.

1 answer

Log in to vote
0
Answered by 5 years ago

This has been solved on the community Discord server.

Ad

Answer this question