V 9/9/2015
Ok so I decided to go a different route. Im going to use the magic of the "target" builtinfunction to reference each tile.
This has the benefit of not having to keep a massive table of data and i can keep track of whether a current tile is selected or not. I started coding and got real excited when I started to get a system that worked here it is:
Bin = script.Parent hasoldtarget = false oldtarget = nil function onButton1Down(mouse) target = mouse.Target if target.Name == "Plot" then target.BrickColor = BrickColor.new(21) if hasoldtarget == false then target.BrickColor = BrickColor.new(22) oldtarget = target hasoldtarget = true return end if hasoldtarget == true and oldtarget ~= target then oldtarget.BrickColor = BrickColor.new(0) target.BrickColor = BrickColor.new(24) oldtarget = target print(oldtarget) return end if hasoldtarget == true and oldtarget == target then oldtarget.BrickColor = BrickColor.new(0) target.BrickColor = BrickColor.new(0) oldtarget = target return end end end function onButton2Down(mouse) target = mouse.Target if target.Name == "Plot" then target.BrickColor = BrickColor.new(23) end end function onSelected(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button2Down:connect(function() onButton2Down(mouse) end) end Bin.Selected:connect(onSelected)
IT WORKS!!!...BUT ONLY IN THE STUDIO!!! fml...
Quick rundown of how code works. I'm essentially trying to keep track of what tile is being selected. The code looks at the target clicked and stores it. It then changes the color of the tile based on whether or not it is a tile (called 'em "plots") from last click or a new one. The colors are as follows
Pink(22) = the first selected tile (player is using the tool for the first time so there is no stored previous)
Yellow(23)= The current selected tile (I plan to add building functionality with the right click and all it will need to do is check if the "plot"color is yellow)
Grey(0)=A previously selected, but now un-selected tile (Selecting the same plot twice will de-select)
I thought it was a pretty lightweight solution but for WHATEVER reason the code doesn't run on an actual server. The gun cursor wont even load (mouse.Icon = "rbxasset://textures\GunCursor.png")
Studio is blind to LocalScripts and Scripts.
If you really wanted to, you could use a Script for a LocalScript instead, but only in Studio.
You may be using the wrong script.