I want to put texts in module script by using script to use it in other scripts
In script which i add this it shows,as not nil, but in another script it say it is nil.
I tried a lot of thinks from chaging scripts parents to rewriting scripts,but nothing worked.
Script which change module script:
local rs = game:GetService("ReplicatedStorage")
local UnActivatePet = rs:WaitForChild("RemoteEvents"):WaitForChild("UnActivatePet")
local AutoDelete = require(script.Parent.AutoDelete)
UnActivatePet.OnServerEvent:Connect(function(player,pet,unactivated)
if unactivated == true then
table.insert(AutoDelete,pet)
elseif unactivated == false then
local FoundPet = table.find(AutoDelete,pet,1)
table.remove(AutoDelete,FoundPet)
end
end)
Script which should get info from module script:
local ReplicatedStorageService = game:GetService("ReplicatedStorage")
local PlayersService = game:GetService("Players")
local Player = PlayersService.LocalPlayer
local RemoteEvent = ReplicatedStorageService:WaitForChild("RemoteEvents"):WaitForChild("CheckDisabledPet")
local RemoteEvent2 = ReplicatedStorageService:WaitForChild("RemoteEvents"):WaitForChild("CheckDisabledPetEnded")
local AutoDelete = require(script.Parent.AutoDelete)
RemoteEvent.OnClientEvent:Connect(function(petName)
local Think = table.find(AutoDelete,petName,1)
if Think ~= nil then
RemoteEvent:FireServer(true,petName)
elseif Think == nil then
RemoteEvent:FireServer(false,petName)
end
end)
If you need more information, just ask.
Also scripts location:
First is script which change module script.
Second is script which get the info from module script.
Third is module script(i think it’s easy to understand).
Server and client have “different” modules. The client does not see the changes that the server has made, and the server does not see the change that the client has made.
I know i created remote event and sended all values to it and then put the rest of code into it.
If you want to see here:
Server Script:
local rs = game:GetService("ReplicatedStorage")
local UnActivatePet = rs:WaitForChild("RemoteEvents"):WaitForChild("UnActivatePet")
local RemoteEvent2 = rs:WaitForChild("RemoteEvents"):WaitForChild("UNACTIVATEPET")
local AutoDelete = require(script.Parent.AutoDelete)
UnActivatePet.OnServerEvent:Connect(function(player,pet,unactivated)
--if unactivated == true then
-- table.insert(AutoDelete,pet)
-- print(AutoDelete[1])
--elseif unactivated == false then
-- local FoundPet = table.find(AutoDelete,pet,1)
-- table.remove(AutoDelete,FoundPet)
--end
UnActivatePet:FireClient(player,pet,unactivated)
end)
Local Script:
local rs = game:GetService("ReplicatedStorage")
local RemoteEvent = rs:WaitForChild("RemoteEvents"):WaitForChild("UNACTIVATEPET")
local AutoDelete = require(script.Parent.AutoDelete)
RemoteEvent.OnClientEvent:Connect(function(pet,unactivated)
if unactivated == true then
table.insert(AutoDelete,pet)
print(AutoDelete[1])
elseif unactivated == false then
local FoundPet = table.find(AutoDelete,pet,1)
table.remove(AutoDelete,FoundPet)
end
end)
I don’t think you’re understanding how ModuleScripts work. You don’t “put things into” ModuleScripts. When you require a ModuleScript, you receive a new instantiated object determined by the module. If you require a ModuleScript from two different places, the objects you receive in each location are different objects. This means that if you required a table from a ModuleScript twice, you will receive clone tables that have no relation to each other. The changes that you make to one will not be reflected in the other. They are separate instances of tables that are stored in different locations in memory. I think you should rework your scripts so that you’re using the same instance table from anywhere in your code. You need to store that table instance in a location where any scripts can see it and modify it.
Thank you, i didn’t know that. Maybe i just should put 2 codes into 1 script and create table in it? Cuz i only need to check if this name is in this table.
Wait a sec you aren’t right @xendatro , @3YbuKtOp is right, @3YbuKtOp sorry i just used wrong event in first script i should use RemoteEvent2 to give data, not UnActivatePet. Sorry for confusing you @3YbuKtOp .