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

How to send data from one server script to another without remote events?

I'm creating is gun, and each bullet has its own individual script for hit detection and bullet physics and stuff like that. However, the problem is I'm trying to pass the data from the gun the player is holding to the bullet, that way I can tell the bullet to ignore the player when it comes to hitting detection. The problem is I don't want to use remote events, because I don't want a million remote events triggering if multiple people are firing the gun at once, cause that would create a lot of lag. And I don't know any other way to send information between scripts without remote events.

3 comments

0

they use remote events, also why arent you handling this client side

0

1: im trying to keep as little on there as possible to avoid exploiters ; 2 - The script im trying to send information to is inside the bullet bullet, so I need to use a server script

0

BindableEvents are your best bet, there is also _G.

1 answer

✓ Accepted answer

You could use ObjectValues for this, example: Main Tool Script:

local BulletScript = bullet:FindFirstChild("Script")
local ObjValue = BulletScript:FindFirstChild("Player")
ObjValue.Value = Player

Bullet Script:

local PlrValue = script:FindFirstChild("Player")
local Player = PlrValue.Value

function BulletHit(Object)
if not Object:IsDescendantOf(Player) then
print("Object is not the firing player's character, check if it's another player and damage")
end
end

Of course, this isn't a full script, just enough to give you an idea of how you can use ObjectValues in your code, Hope this helps Also, you could use ModuleScripts for this if the above doesn't help

3 comments

0

Lord_WIthAlt, so I tried this, and in my mind it makes sense, but for some reason, its acting very strange. I've tried it, and for me it appears to only work when I do a regular if statement, not an "if not" statement. When I use an if statement the bullet does not kill me even though it by all accounts should, when I use an "if not" statement then it does kill me. :Edit: Actually neither of them

0

Wait, thats my fault I was doing a double negative with the if statements, it works fine, thanks for the help.

0

Sorry for the late reply, no problem, glad I could help

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