Feel free to use it then. No one’s stopping you.
I have one question how do i make a variable that is the all names in the module? Can you pls help?
Sorry, I don’t think I understood your question.
like i want to detect if the tool is named like one of the module tool names but in one variable i think i can do it with or
hey can you give me a example local script with a function that detects if a tool in character is named one of the module tool names and then if true return tool.Name
Sorry, I currently can’t since I’m on mobile and barely any connection, but I will try to answer later.
alright then im gonna continue the action bar later bc its not really necessary.
Hello!
I will try to show you the way and give you a little bit of a start by unifying every one of my responses into a single text:
In SCP: CB, they use a single, giant script which has almost everything inside it, including the function of the action bar. However, splitting code into multiple scripts is better because of obvious reasons.
Let’s imagine you have a Tool called Pizza, and you want a text to pop up when it is eaten. So you create a Local Script inside it and connect it to Tool.Activated
, which is a Event. You can connect to events like this:
script.Parent.Activated:Connect(function()
-- Tool Activated!
end)
Like 4PackAbs said:
[…] also he suggested using bindable events which is better
I would really recommend you to use an event system for this, since you can just call the event inside the Activation part and be done with. Module Scripts are useful, but not for this task. It is just not that great in the long run. What if you want two messages for one tool? It can be done, but requires more coding, and it will make things uselessly more complicated.
So I can show you how to make it with an Event, which Roblox has also a guide of here. All you have to do is to create a BindableEvent, for example, in the ReplicatedStorage. Then use BindableEvent:Fire()
to fire the event out. You can also pass arguments in events, so you could too send a message with it like this.
BindableEvent:Fire(message)
Inside your GUI Element, create a local script and connect the event there like this:
BindableEvent.Event:Connect(function(message)
-- Message received!
end)
So in your Pizza Script, it could look like this:
script.Parent.Activated:Connect(function()
BindableEvent:Fire("You ate the Pizza")
end)
Then inside your GUI Element Script, where you received the message, there you could process the rest. So every time a Player would click with the Pizza equipped, a text message would be sent. Following this, you can just reference the GUI Element per script.Parent
, change the text to the message you received and toggle its Visible
Property like you already have programmed in your first script.
I really hope I could clarify your confusion, and help with your projects! This is every resource you need to get it running, and I really think you can puzzle the rest together.
Good Luck!