Hello, I want it so if u click a part it will fire a remote then there gets something printed but it won't work ;/.
here is how its all positioned: http://prntscr.com/giaa7h here is the code: serverscript thingy:
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("Remote") remote.OnServerEvent:connect(function() print("SICK DUDE U CLICKED DA BRICK") end)
the local script in the brick:
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("Remote") script.Parent.ClickDetector.MouseClick:connect(function() remote:FireServer() end)
But now this does nothing HELP!
RemoteEvents are only used for client-server communication or vice-versa. Do not ever put a localscript as a descendant in workspace unless it's inside of a player's Character. Since both scripts are server-sided, you want to have both of them inside of a script.
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("Remote") script.Parent.ClickDetector.MouseClick:connect(function() print("SICK DUDE U CLICKED DA BRICK") end)
If you really wanted to have communication between different scripts, use a BindableEvent
script 1:
local repStorage = game:GetService("ReplicatedStorage") local bindable = repStorage:WaitForChild("BindableEvent") script.Parent.ClickDetector.MouseClick:connect(function() bindable:Fire() -- fires bindable when clicked end)
script 2:
local repStorage = game:GetService("ReplicatedStorage") local bindable = repStorage:WaitForChild("BindableEvent") bindable.Event:Connect(function() -- connects function when bindable is fired print("SICK DUDE U CLICKED DA BRICK") end)