I'm confused as to how all of this works. I made a Remote Event in Replicated Storage named "GearGet" I then tried moving the script to a local script and put it in starter player scripts, after tweaking it a little:
01 | local replicatedStorage = game.ReplicatedStorage |
02 | local GearGetRemote = replicatedStorage:WaitForChild( "GearGet" ) |
04 | local pointPart = game.Workspace.FullGear.GearGiver |
06 | local blue = Color 3. fromRGB( 0 , 0 , 255 ) |
07 | local green = Color 3. fromRGB( 0 , 255 , 0 ) |
10 | local Players = game:GetService( "Players" ) |
13 | GearGetRemote.OnClientEvent:Connect( function (otherPart) |
14 | local humanoid = otherPart.Parent:FindFirstChild( 'Humanoid' ) |
15 | local player = game.Players:FindFirstChild(otherPart.Parent.Name) |
16 | local currentColor = pointPart.Color |
17 | local model = game.Workspace.FullGear.Gear |
18 | if humanoid and player and canGet and currentColor = = blue then |
20 | player.leaderstats.Gears.Value = player.leaderstats.Gears.Value + 1 |
21 | print ( "Giving player gear" ) |
22 | pointPart.Color = green |
23 | for i, block in model:GetChildren() do |
24 | if block:IsA( "Part" ) or ( "UnionOperation" ) then |
25 | block.Transparency = 0.5 |
26 | elseif humanoid and player and canGet and currentColor = = green then |
27 | print ( "Player already recieved gear" ) |
(I'm ignoring the "onTouch2" function from the original script for now)
I also have a server script in Server Script Service that says this:
1 | local replicatedStorage = game.ReplicatedStorage |
2 | local GearGetRemote = replicatedStorage:WaitForChild( "GearGet" ) |
4 | GearGetRemote.OnServerEvent:Connect( function (player,...) |
9 | GearGetRemote:FireAllClients() |
I don't know how to fire the GearGet Remote event when someone touches pointPart though. I feel like I'm over thinking it, I looked up a yt tutorial on how to use Remote Events and I don't really understand it