Hello! I have many “interactable” objects in my game, and I am curious on what the best way to optimize this is. I am using raycast to see when the player is looking at an object and if they hit E to interact with it. Right now, I am using CollectionService to group every different task the player may need to interact with–opening a door, lockpicking a door, etc. Is there a better way to do this? I thought about using a script for every interactable item, but that is not a good way to go with 50+ scripts and many doing the same task. Thank you for your time!
Modulescript is for that
obivously take advantage of it and dictiornaries, arrays (and learing, tutorials)
and You can’t trust client, you need make strict Anti cheat for handling
ModuleScript for functions and etc
local m={
["Door"]=-- Door function
["Lockpicking"]=-- Lockpicking function
["Vent"]=-- Vent function
}
return m
This is Handling
local m0=require(modulescript)
local m={}
function m.CheckIn(plr: Player,a: String)
if a:HasTag("Int") then
for i,v in m0 do
if a=i then
v()
end
end
end
end
return m
-- in some server-side script --
WhateverRemoteEvent.OnServerEvent:Connect(m.CheckIn)
You can use Tag on Instances
Pre-Make the Assests (Door,Vent and etc)
not the best i provided
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.