micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 30 Jul 2014 08:02 PM |
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local part = Instance.new("Part", game.Workspace) part.TopSurface = "Smooth" part.BottomSurface = "Smooth" part.Transparency = .5 part.Name = plr.Name.."brick" part.Anchored = true part.CanCollide = false local brick = game.Workspace[plr.Name.."brick"] mouse.TargetFilter = brick local model = game.Workspace.localmodel
mouse.Move:connect(function(moved) if mouse.Target.Name:Sub(1,5) == "Green" and mouse.Target.Select.Value == false then brick.BrickColor = BrickColor.new("Medium stone grey") a = model:GetModelSize() local z = a.z local x = a.x local g = Vector3.new(x,0.2,z) brick.Size = g brick.CFrame = mouse.Target.CFrame+Vector3.new(0,0.1,0) else brick.BrickColor == BrickColor.new("Bright red") end end)
mouse.Button1Down:connect(function() model:MoveTo(brick.Position) model.pos.Value = brick.Position end)
What I want to do is when the brick moves over in the game with bricks called "Green" with a bool value inside called select, I want it to turn their select to true. However when I click to another position after that I want to unselect then select the new bricks that are called "Green" in workspace. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 30 Jul 2014 08:03 PM |
| By the way I tried using touched and touchended with tables however that doesn't work. Anyone got another idea? |
|
|
| Report Abuse |
|
|
Ludav
|
  |
| Joined: 28 Jul 2014 |
| Total Posts: 112 |
|
|
| 30 Jul 2014 08:07 PM |
I'm assuming this is in a local script, correct? If not, it wont work, as you cannot get the players mouse within a script. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 30 Jul 2014 08:08 PM |
| It is in a local script, however I want to get Parts in workspace that are connected to my Brick. When my brick moves over them I want to add them to a table then if I click I want the table to be selected and the ones before that unselected. |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 08:08 PM |
Finally. See, we can help you like this.
First off, let's take the script apart.
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local part = Instance.new("Part", game.Workspace) part.TopSurface = "Smooth" part.BottomSurface = "Smooth" part.Transparency = .5 part.Name = ""..plr.Name.."brick" -- You forgot two quotations in the front part.Anchored = true part.CanCollide = false -- local brick = game.Workspace[plr.Name.."brick"] This line becomes unnecessary as the brick is already defined as "part" mouse.TargetFilter = brick local model = game.Workspace.localmodel --Okay. Is there more than one "localmodel?"
mouse.Move:connect(function() p = mouse.Target if p.Name == "Green" and mouse.Target.Select.Value == false then --These blocks have the Select bool right? p.BrickColor = BrickColor.new("Medium stone grey") a = model:GetModelSize() local z = a.z local x = a.x local g = Vector3.new(x,0.2,z) part.Size = g part.CFrame = mouse.Target.CFrame+Vector3.new(0,0.1,0) else part.BrickColor == BrickColor.new("Bright red") end end)
mouse.Button1Down:connect(function() model:MoveTo(part.Position) model.pos.Value = part.Position end)
Those are some of the technical errors; not sure about the actual functions. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 30 Jul 2014 08:12 PM |
| Yes however I tried using touched and touch ended with a table but it didn't work. I want to turn the select bool value to true when mouse.Button1Click:connect happens. Because then I can make sure nothing goes under the model I'm :MoveToing. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
| |
|