The one that randomizes the text? Or the one whith the RemoteFunctions?
wouldn’t TextLabel.Text work?
I mean just get the text after you changed it
Both please. To check them. Please
You can assign the textlabel in your script as a variable and when the remote function fires you fire server with the textlabel.
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print(player.Name)
local names = {"Monica", "Joey", "Sarah", "Phoebe", "Michel", "Michael", "James", "Adam", "ElectroShop", "Cablebar" ,"Airedable" ,"Tv.Inc", "Videosify", "Tellyware", "Onaired", "Remixus", "Technomax", "Elevatelly", "Envideos", "Inc.ia", "Cotv", "Coremix", "Edaired", "Unitelly"}
wait(5)
local ReplicatedStorage = game.ReplicatedStorage.RemoteFunctions.AbortFunctions.Order1.Order1Function
local tvOrdersRMD = {"OldTv", "Salora 58UA330"}
local orders = player.PlayerGui.ComputerMenu.Orders.Background1.Orders
local OrderParent = player.PlayerGui.ComputerMenu.Orders.Background1
-- The 1st parameter defaults to 1 if it's not specified, so in this case we can just put #companyNAMES to find the max number in the table.
local randomtask2 = math.random(#names)
local index
local index2
wait(10)
for i = 1, 6 do
index = math.random(#names)
index2 = math.random(#tvOrdersRMD)
local Order = OrderParent["Order"..i]
Order.Visible = true
Order.Text = "Name: ".. names[index]
Order.TVSelecter.Text = "Order: "..tvOrdersRMD[index2]
orders.Value += 1
local OrderValue = Instance.new("BoolValue")
OrderValue.Name = tvOrdersRMD[index2]
OrderValue.Parent = ReplicatedStorage
wait(70)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Order = Instance.new("RemoteFunction")
Order.Parent = ReplicatedStorage
Order.Name = "CreateOrderRequest"
local function orderRequest(player)
end
Order.OnServerInvoke = orderRequest()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OrderFunction = ReplicatedStorage:WaitForChild("CreateOrderRequest")
script.Parent.MouseButton1Click:Connect(function()
local Order = OrderFunction:InvokeServer()
end)
I wish it was that easy, but no. Cause its created with Instance.new().
Try something like this:
local Order = Instance.new("RemoteFunction")
Order.Parent = ReplicatedStorage
Order.Name = "CreateOrderRequest"
local function orderRequest(player, text)
print(text)
end
Order.OnServerInvoke = orderRequest
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OrderFunction = ReplicatedStorage:WaitForChild("CreateOrderRequest")
script.Parent.MouseButton1Click:Connect(function()
-----------I dont know where is the label so you can change the "script.Parent.Name"
local Order = OrderFunction:InvokeServer(script.Parent.Name)
end)
This is unnecessary cause it doesn’t do anything or i am totally wrong that could be true tho…
And I forgot to change the title cause its a boolvalue created with Instance.new(). And with that value it will be having the same name as the randomized order as you can see in the script.
And I can’t figure out how I can make it that the second script knows what the name of the value is.
But if you know an other way to do this that also would be great!!
Instance.new()
returns the instance that you made. Here is an example:
local newInstance = Instance.new("Part")
newInstance.BrickColor = BrickColor.new("Really Red")
newInstance.Name = "EEEEEE"
newInstance.Parent = game:GetService("Workspace")
To make it cross-script (allow other scripts to know what it is), depending on how your game works, the other script can listen for it added via ChildAdded/DescendantAdded, or you can send the script the value via a BindableEvent.
I have coded a concept that might help you/give you idea
--Services
local Players = game:GetService("Players")
--Variables
local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local screenGui = PlayerGui:WaitForChild("ScreenGui")
local Frame = screenGui.Frame
--Table
local names = {"Monica", "Joey", "Sarah", "Phoebe", "Michel", "Michael", "James", "Adam", "ElectroShop", "Cablebar" ,"Airedable" ,"Tv.Inc", "Videosify", "Tellyware", "Onaired", "Remixus", "Technomax", "Elevatelly", "Envideos", "Inc.ia", "Cotv", "Coremix", "Edaired", "Unitelly"}
--Code
local folder = Instance.new("Folder")
folder.Parent = Frame
local index = math.random(#names)
local txtBoxWithRunName = Instance.new("TextBox")
txtBoxWithRunName.Name = names[index]
txtBoxWithRunName.Parent = folder
local getTextWithRunName = folder:GetChildren()
for i, child in ipairs(getTextWithRunName) do
print(child.Name)--The Child is the random name textbox
end
--[[
Instance a new folder before instancing the text label which you would know the name of it then inside that folder instance the text label with the random name.
Then to access it access the file and GetChildren()
Hope this suggestion helps
]]
I will test that out for sure! And I am pretty sure that that is a solution but ima try it out first.
I had that same idea before and I tried it out. But the problem is that if he/she accepted more orders then there will be more values and it will return all of them. And I don’t want that to happen yet… But if the time is there and the players want that I will use that for sure.
One last question:
How can I send the BoolValue with the random name to the otherscript? Cause so far I only have this…;
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print(player.Name)
local names = {"Monica", "Joey", "Sarah", "Phoebe", "Michel", "Michael", "James", "Adam", "ElectroShop", "Cablebar" ,"Airedable" ,"Tv.Inc", "Videosify", "Tellyware", "Onaired", "Remixus", "Technomax", "Elevatelly", "Envideos", "Inc.ia", "Cotv", "Coremix", "Edaired", "Unitelly"}
wait(5)
local ReplicatedStorage = game.ReplicatedStorage.RemoteFunctions.AbortFunctions.Order1.Order1Function
local tvOrdersRMD = {"OldTv", "Salora 58UA330"}
local orders = player.PlayerGui.ComputerMenu.Orders.Background1.Orders
local OrderParent = player.PlayerGui.ComputerMenu.Orders.Background1
-- The 1st parameter defaults to 1 if it's not specified, so in this case we can just put #companyNAMES to find the max number in the table.
local randomtask2 = math.random(#names)
local index
local index2
wait(10)
for i = 1, 6 do
index = math.random(#names)
index2 = math.random(#tvOrdersRMD)
local Order = OrderParent["Order"..i]
Order.Visible = true
Order.Text = "Name: ".. names[index]
Order.TVSelecter.Text = "Order: "..tvOrdersRMD[index2]
orders.Value += 1
local OrderValue = Instance.new("BoolValue")
OrderValue.Name = tvOrdersRMD[index2]
OrderValue.Parent = ReplicatedStorage
wait(70)
if OrderValue then
local BindableEvent = game.Workspace:WaitForChild("AcceptOrder")
BindableEvent:Fire()
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Order = Instance.new("RemoteFunction")
Order.Parent = ReplicatedStorage
Order.Name = "CreateOrderRequest"
local BindableEvent = game.Workspace:WaitForChild("AcceptOrder")
local function orderRequest(player, text)
BindableEvent.Event:Coccent(function()
end)
end
Order.OnServerInvoke = orderRequest
Can you guys help me with that? @iamtryingtofindname, @CrazySnoopylove
Look into Remote Events and send that value with a remote event or another solution would be to set a value/attributes and detect .Changed()
I’ve been doing some scripting but, the only thing is that it doesn’t says the randomized name of the BoolValue even tho I send it to the other script.(Not sure about that… the script may be incorrect)
And if I put a print statement it doesn’t prints it. Here’s the script;
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print(player.Name)
local names = {"Monica", "Joey", "Sarah", "Phoebe", "Michel", "Michael", "James", "Adam", "ElectroShop", "Cablebar" ,"Airedable" ,"Tv.Inc", "Videosify", "Tellyware", "Onaired", "Remixus", "Technomax", "Elevatelly", "Envideos", "Inc.ia", "Cotv", "Coremix", "Edaired", "Unitelly"}
wait(5)
local ReplicatedStorage = game.ReplicatedStorage.RemoteFunctions.AbortFunctions.Order1.Order1Function
local tvOrdersRMD = {"OldTv", "Salora 58UA330"}
local orders = player.PlayerGui.ComputerMenu.Orders.Background1.Orders
local OrderParent = player.PlayerGui.ComputerMenu.Orders.Background1
-- The 1st parameter defaults to 1 if it's not specified, so in this case we can just put #companyNAMES to find the max number in the table.
local randomtask2 = math.random(#names)
local index
local index2
wait(10)
for i = 1, 6 do
index = math.random(#names)
index2 = math.random(#tvOrdersRMD)
local Order = OrderParent["Order"..i]
Order.Visible = true
Order.Text = "Name: ".. names[index]
Order.TVSelecter.Text = "Order: "..tvOrdersRMD[index2]
orders.Value += 1
print(Order)
local OrderValue = Instance.new("BoolValue")
OrderValue.Name = tvOrdersRMD[index2]
OrderValue.Parent = ReplicatedStorage
print(OrderValue.Name)
local bf = game.Workspace:WaitForChild("AcceptOrder")
print(bf)
bf:Invoke(OrderValue)
print(OrderValue)
wait(70)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
And
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Order = Instance.new("RemoteFunction")
Order.Parent = ReplicatedStorage
Order.Name = "CreateOrderRequest"
print("OK1")
local bf = game.Workspace:WaitForChild("AcceptOrder")
local function orderRequest(player, text)
print(player)
end
Order.OnServerInvoke = orderRequest
local function AcceptOrder(player)
print("ok")
print(bf)
end
bf.OnInvoke = AcceptOrder
When you are randomizing the names, I assume you are using some sort of key for encrypting it, if you’re not, I suggest you do so and then you can use the same key to decrypt names when you need to.
Can you show me an example please? Or a link, if that goes faster.(so you don’t have to type…)
Sure, here’s a simple encryption/decryption using Caesar cipher. Basically, the idea is to take a peice of string and shift each character down/up by a fixed number of positions (character codes).
For this, we will use two functions of the string library: string.byte and string.char. The first one returns the internal numerical code for the character passed as the first argument and the second one returns the character for the internal numerical code passed as the first argument.
local function Encrypt(textToEncrypt, shiftAmount)
local encrypted = ""
for i = 1, text:len() do
local internalNC = textToEncrypt:sub(i, i):byte()
encrypted = encrypted .. string.char(internalNC - shiftAmount)
end
return encrypted
end
local function Decrypt(textToDecrypt, shiftAmount)
local decrypted = ""
for i = 1, text:len() do
local internalNC = textToDecrypt:sub(i, i):byte()
decrypted = decrypted .. string.char(internalNC + shiftAmount)
end
return decrypted
end
local encryptedText = Encrypt("Hey!", 3)
print(encryptedText) --> Ebv
local decryptedText = Decrypt(encryptedText, 3)
print(decryptedText) --> Hey!
Hope this helps! (sorry I went afk for a while there )
Edit: There are more complex and reliable encryption algorithms you can and should take a look at, I used the caesar cipher as an example, it is not really safe and easily broken down.
But how can this work with randomized text? Cause if I have the script as above then it doesn’t prints the randomized name.