How would I make a credit card tool, when you hold it, it opens a UI, then the UI has a randomly generated number as the card number. How do I randomly generate a number per each person and save that number for each game?
My current scripts are as follows:
https://gyazo.com/319be8392102647b53396d7bcb65cfe2 https://gyazo.com/0471345f1094227aca81e991696b552f https://gyazo.com/42ab2650d1132241290206567e1a30fd
LocalScript:
script.Parent.Equipped:Connect(function() local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = ReplicatedStorage:WaitForChild("RemoteEvent") createPartEvent:FireServer() local RandomFirstDigit = math.random(1,9) local RandomSecondDigit = math.random(1,9) local RandomThirdDigit = math.random(1,9) end)
Script:
-- Script local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage) local function onCreatePartFired(player) game.StarterGui.ScreenGui.Frame.Visible = true end createPartEvent.OnServerEvent:Connect(onCreatePartFired)
You should have three text labels in the screen gui. Number1,Number2 and Number3 then in the local script try this
local number1 = game.StarterGui.ScreenGui.Frame.Number1 local number2 = game.StarterGui.ScreenGui.Frame.Number2 local number3 = game.StarterGui.ScreenGui.Frame.Number3 local ui = number1.Parent.Parent script.Parent.Equipped:Connect(function() ui.Enabled = true local one = math.random(1,9) local two = math.random(1,9) local three = math.random(1,9) number1.Text = one number2.Text = two number3.Text = three end) script.Parent.Unequipped:Connect(function() ui.Enabled = false end)
And that should work. You dont need the normal script or the events or whatever.