Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can you check if a player is in a table from another script?

So I'm making a feature not specifying what feature, But in the MainScript I have a table with every player, So in another script I want to give every player in the table more speed, But I can't figure out how, I tried many things, May anyone help me?

1 comment

0

You can use bindable events or remote event/functions

2 answers

✓ Accepted answer

I think you are going to need to post more context, but here is my answer from I can obtain.

Assuming both scripts are server sided:

local event = game.ReplicatedStorage.BindableEvent  -- some event you have

event.Event:Connect(function(players)
	for i, player in pairs(players)  do
		local char = player.Character or player.CharacterAdded:Wait()

		char.Humanoid.WalkSpeed += 10 -- increases speed
	end
end)


-- in the main script

local event = game.ReplicatedStorage.BindableEvent

local players = {} -- your table

event:Fire(players) -- this is how you fire the server, call this whenever you need to increase the speed

1 comment

0

Thanks

The most efficient option is to use ModuleScripts, as you can then access tables directly (if you put the table in what is returned by the Module), example:

Module Script:

local module = {}
local someTable = {}
module.SomeTable = someTable
-- can use someTable here
return module

Script:

local Module = require(path.to.module.script.here)
-- You can now use Module.SomeTable here

2 comments

0

Sorry, I already accepted someone elses answer

0

But thanks for trying to help

This discussion is preserved as it was. New answers, comments, and votes are closed.