Yes, a RemoteEvent. Sure.
local detector = script.Parent.Detector -- The click detector. detector.MouseClick:connect(function(plr) plr.PlayerScripts.IntValue.Value = plr.PlayerScripts.IntValue.Value -1 -- Basically I need to change values. end)
Okay so look this is hard to explain.
But I can't use a RemoteEvent with the click detector local, and then telling the server who clicked it. Why? I need to clone the script and put it in bricks. If the same script that is waiting for this code
Event.OnServerEvent:connect(function()
then let's say there's 25 parts with the same script in it, the scripts would all then get fired, right?
So I need a way around the server calling all 25 scripts to do the action. I have tried this, and it is what happened.
So
I am wondering, what would I do? I have tried custom coding the whole click detector using Mouse.Target and such. I am extremely lost, if you need more examples message me.
Yea, I just started learning FE and it is confusing at first, but you'll get it with practice.
So, with FE enabled, the game is practically in two (or how I view it), the server (What everyone else sees) and the client (What the player sees). In your case, you're wanting the player to click a brick or click one of the bricks in a group of bricks to do something.
So if this was one brick, you would do:
-- Client Side, could be placed in StarterPlayerScripts game.Workspace.ClickThis.ClickDetector.MouseButton1Click:connect(function() -- event game.ReplicatedStorage.Event:FireServer() -- Client to Server, so you FireServer()(Event=RemoteE) end)
-- Server Side, could be placed inside your ClickDetector or ServerScriptService game.ReplicatedStorage.Event.OnServerEvent:connect(function() -- So when Event is fired/called -- Stuff you want done. Remeber, this will change stuff on the server-side not locally end)
Multiple Bricks would be the same exact thing, but you'd create a table with 'in pairs' and the bricks need to be in a model:
for i,v in pairs (game.Workspace.Model:GetChildren()) do -- gets all the children of the model v.ClickDetector.MouseButton1Click:connect(function() -- each brick has a clickDetector game.ReplicatedStorage.Event:FireServer() end) end