Computer hacking system help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am making a ModuleScript through which I can access all the stuff at once. Here I wanted that in the workspace there is a computer and I wanted to hack it, so I would have to touch a part to make the GUI pop up. After that I can do the rest.

  2. What is the issue? Include screenshots / videos if possible!
    I tried this far:

local computerModule = {}

function computerModule.Activate(computerFolder)
	for _, computer in pairs(computerFolder:GetChildren()) do
		if computer:FindFirstChild("TouchPart") then
			computer.TouchPart.Touched:Connect(function()
				game.StarterGui.ScreenGui.ProgressBarBG.Visible = true
			end)
		else
			warn("TouchPart unavailable")
		end
	end
end

return computerModule

image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did but all I found was the touch to make gui visible to true. Click here to find it

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Edit: Any help will be really appreciated as I’m not a good scripter (Average)

1 Like

Are you requiring the module and not just defining it?

I did require the script at the beginning.

Try rearranging the module start to computerModule.Activate = function(computerFolder)

Edit:

Quick rewrite of your code.

local computerModule = {}

computerModule.Activate = function(computerFolder)
	for _, computer in pairs(computerFolder:GetChildren()) do
		if computer:FindFirstChild("TouchPart") then
			computer.TouchPart.Touched:Connect(function()
				game.StarterGui.ScreenGui.ProgressBarBG.Visible = true
			end)
		else
			warn("TouchPart unavailable")
		end
	end
end

return computerModule
1 Like

It didn’t work. Also I tried using if statement to check if it was a Humanoid or not. But still didn’t work.

Are you getting any console errors?

Not at all, all I got was my plugin errors nothing else.

Have you tried debugging with prints?

1 Like

Wait I’ll try to, might work I don’t know…

I’ve a question, does :GetChildren("TouchPart") work?

No it won’t, GetChildren returns a table of objects.

Yes, that’s also right…I’ll try more stuff.

Don’t use game.StarterGui that’s just a service for things to get replicated to the player’s PlayerGui. Whatever changes are made there aren’t seen. You would have to fire a remote event to the client to enable the gui

Edit: replied to the wrong person

1 Like

Instead of checking with findfirstchild use WaitForChild

First, Do not do this, WaitForChild yeilds until the object is found, if it doesn’t exist you’ll infinitely yeild.

Second, StarterGui is a service that replicates gui to the PlayerGui and all you’ll be doing is changing this object from the server.

For what you’re attempting to do will not work and you’ll need to fire to the client telling it to open a specific gui object.

An example of this would be something like this:

--// Server \\--
local Players = game:GetService("Players");
local ReplicatedStorage = game:GetService("ReplicatedStorage");

local computerFolder = workspace.ComputerFolder; --// Wherever this folder is.
local guiRemote = ReplicatedStorage.GuiRemote; --// Preferred remote to tell the client.

for _, computer in ipairs(computerFolder:GetChildren()) do
	local touchPart = computer:FindFirstChild("TouchPart");

	if touchPart then
		touchPart.Touched:Connect(function(touched)
			local character = touched.Parent;

			if character then
				local player = Players:GetPlayerFromCharacter(character);
				
				if player then
					guiRemote:FireClient(player, "ProgressBarBG", true);
				end
			end
		end)
	end
end

--// Client \\--
local Players = game:GetService("Players");
local ReplicatedStorage = game:GetService("ReplicatedStorage");

local LocalPlayer = Players.LocalPlayer;
local PlayerGui = LocalPlayer.PlayerGui;

local ProgressBarBG = PlayerGui.ScreenGui.ProgressBarBG; --// Location of the gui.
local guiRemote = ReplicatedStorage.GuiRemote;

guiRemote.OnClientEvent:Connect(function(gui, enabled) --// If you plan to do multiple guis you should make something more advanced.
	if gui == "ProgressBarBG" then
		ProgressBarBG.Visible = enabled or false;
	end
end)

Remember this is an example and is prone to errors.