More Efficient Scripting (Local to Server script Remote Events) [SOLVED]

So your using this script in all of them?

local repplcmt = game:GetService(“ReplicatedStorage”).POVComps.BBComics.CopyComicPlacements
local reptools = game:GetService(“ReplicatedStorage”).POVComps.BBComics.ComicTools
local ComicPlacement = script.Parent

for _, v in pairs(repplcmt:GetChildren()) do
v.OnServerEvent:Connect(function(Player,ToolName)
print(“Event fired”)
local ComicTool = reptools:FindFirstChild(ToolName)
ComicTool.Parent = game.Workspace
ComicTool.Handle.CFrame = ComicPlacement.CFrame
ComicTool.Handle.Anchored = true
end)
end

I just added line to destroy the tool the player is holding when they click on the part but yeah it is the same script in each.

local repplcmt = game:GetService("ReplicatedStorage").POVComps.BBComics.CopyComicPlacements
local reptools = game:GetService("ReplicatedStorage").POVComps.BBComics.ComicTools
local ComicPlacement = script.Parent

for _, v in pairs(repplcmt:GetChildren()) do
	v.OnServerEvent:Connect(function(Player,ToolName)
		print("Event fired")
		local ComicTool = reptools:FindFirstChild(ToolName):Clone()
		Player.Character:FindFirstChildWhichIsA("Tool"):Destroy()
		ComicTool.Parent = game.Workspace
		ComicTool.Handle.CFrame = ComicPlacement.CFrame
		ComicTool.Handle.Anchored = true
	end)
end

Are you still having problems with it or is it working now?

Nope :confused: but I think I might just leave the server script as is since it seems to complicated to shrink. At least the local script is much smaller/efficient though

How many remote events are you using?

if I were to make it function for all 16 tools/ComicPlacements it would be like… 200 something I think. So-

Uh i’m pretty sure its possible to just use one

oh- LOL well if there are 16 tools total and 16 possible places to place them on… wouldnt i need a remote event for every single combination of a tool and placement it can go on?

You could just use 1 remote event and send the place you want to put it on position and the name of the tool as arguments

1 Like

Im still new to scripting and ive been learning as i go/plus learning from the help ive gotten here recently. I dont know how to do that yet but maybe i can look more into local to script remote events and stuff.

I can help you if you want, I have loads of free time

1 Like

Thanks! I still will try to look into this though, because thats what I had to do to even get to where I am now. I had to look into using remote events to copy my tool over and make sure it showed for other players in the game as well

1 Like

Okay just message me if you need help, ill respond if I’m not busy

1 Like

ok! I will get back to you maybe tomorrow since it is late for me now. I’ll try to work on it on my own and let you know! I’ll make sure to message you, and thanks again! c:

1 Like

This is what I ended up doing so thanks sm to both of yall for helping. Gonna mark this as the answer, thanks sooo much!

1 Like

You are welcome, there’s no problem

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.