Why does this script work in test/solo play in studio but not online/simulated server?
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:
05 | function onButton 1 Down(mouse) |
08 | if target.Name = = "Plot" then |
10 | target.BrickColor = BrickColor.new( 21 ) |
11 | if hasoldtarget = = false then |
12 | target.BrickColor = BrickColor.new( 22 ) |
17 | if hasoldtarget = = true and oldtarget ~ = target then |
18 | oldtarget.BrickColor = BrickColor.new( 0 ) |
19 | target.BrickColor = BrickColor.new( 24 ) |
25 | if hasoldtarget = = true and oldtarget = = target then |
26 | oldtarget.BrickColor = BrickColor.new( 0 ) |
27 | target.BrickColor = BrickColor.new( 0 ) |
38 | function onButton 2 Down(mouse) |
41 | if target.Name = = "Plot" then |
43 | target.BrickColor = BrickColor.new( 23 ) |
50 | function onSelected(mouse) |
52 | mouse.Button 1 Down:connect( function () onButton 1 Down(mouse) end ) |
53 | mouse.Button 2 Down:connect( function () onButton 2 Down(mouse) end ) |
56 | 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")