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

How can I pass a LocalScript through a Server Script via tool:activated:connect() ?

I'm trying to put Path Givers in my game, and whilst they work fine they are only visible to the player who is creating the Paths. I googled a fix to this and I say someone say on the DevForums that I could pass the Tool's LocalScript through a Server Script by using 'tool:activated:connect()'

Since I'm fairly new to coding I'm not entirely sure how I can do this, can anybody help me understand what I need to do?

1 comment

0

Can you explain what "path givers" are? Anyway, so what I see here is you want communication between a LocalScript and a Script, you can do this via RemoteEvents. You can look into remote events here: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events#client-to-server

1 answer

You should use Remote Events to connect a Server script to Local script and vice versa.

I'll make a little example of how to use it with a tool:

--local script:

local text = 'WOW!'
local event = game:GetService('ReplicatedStorage').RemoteEvent

local tool = script.Parent

tool.Activated:Connect(function()
   event:FireServer(text)
end)

--server script:

local event = game:GetService('ReplicatedStorage').RemoteEvent

event.OnServerEvent:Connect(function(plr, text)
   print(text)
end)

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