When someone spawns, I put a scipt so a folder is put in the character but I want to reference that folder in a separate event. But I can’t figure out how.
Here is the script for the Folder:
script.Parent.Touched:Connect(function(hit)
local Player = hit.Parent
local Folder = Instance.new("Folder",Player)
end)
Is there a reason why you want to pass the reference to another script?
If that’s the case, you should use a BindableEvent and using Event event when the object was fired using Fire() including the reference. The other script would be listening to the event. Connect a function to BindableEvent.Event.
However, I would advise using a one single script for all, as it is more convenient and easier to manage.
I want to clone Instances that you can summon by clicking while holding a tool in the folder (that is in the character) and then later remove them from another tool
Just looking at this, couldn’t you just put a script inside StarterCharacterScripts to create a Folder for the Character that way instead, then detect the Part’s detection?
local DB = false
local PartToTouch = workspace.Part
local Folder = Instance.new("Folder")
Folder.Parent = script.Parent
PartToTouch.Touched:Connect(function(Hit)
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player and not DB then
DB = true
--Do your event firing here
wait(5)
DB = false
end
end)
Then fire the event you want to send throughout the place? Either Server or Local
Oh, I had it backwards! Looks like you want to do something like a clone something from somewhere and parent it to the folder. I don’t have enough information to cover the entire issue, can you forward and elaborate the details? I need a clear idea what you’re trying to achieve.
Basically a Debouce, which pretty much prevents the event from firing multiple times
Say I have this in a infinite loop
local DB = false
while true do
if DB == false then
print("Yes")
DB = true
wait(5)
DB = false
end
wait()
end
The loop is frequently checking every time if the DB is equal to false, and if it is then we can set it as true! But the next time the loop runs through, it’ll pass the conditional check as the DB is still set to true for 5 seconds