generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Selection Box in Mouse Target

Previous Thread :: Next Thread 
UnRandomizing is not online. UnRandomizing
Joined: 20 Jun 2012
Total Posts: 1490
09 Jul 2017 11:57 AM
I tried for a while to get this script to create a selection box around the player mouse's target if it was a specific brick, then delete that selection box when the mouse target is no longer that specific brick. It creates the selection box, but it doesn't delete the selection box when the target changes:

local mouse = game.Players.LocalPlayer:GetMouse()
box = nil
game:GetService("RunService").RenderStepped:connect(function()
local target = mouse.Target

if target then
if target.Name == "ClickPart" then
if not target:FindFirstChild("Selection") then
local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.new(0, 0, 255)
selection.LineThi ckness = 0.15 --space was added due to filter
selection.SurfaceTransparency = 1
selection.Name = "Selection"
selection.Adornee = mouse.Target
selection.Parent = mouse.Target
end
else
if box then
box:Destroy()
end
end
end
end)
Report Abuse
UnRandomizing is not online. UnRandomizing
Joined: 20 Jun 2012
Total Posts: 1490
09 Jul 2017 12:54 PM
You can completely ignore the first few conditional statements, I just need help deleting the selection box when the mouse's target changes.
Report Abuse
UnRandomizing is not online. UnRandomizing
Joined: 20 Jun 2012
Total Posts: 1490
09 Jul 2017 04:05 PM
Anyone?
Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
09 Jul 2017 05:09 PM
Why don't you do the event of mouse.Move and mouse.Leave, and if it leaves an object, then it deletes the selection box.
Report Abuse
UnRandomizing is not online. UnRandomizing
Joined: 20 Jun 2012
Total Posts: 1490
09 Jul 2017 06:49 PM
Sorry, I wasn't sure one existed because I thought there were only GUI events like that.

Thanks, I'll look it up.
Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
09 Jul 2017 06:57 PM
GuiObjects would have:

MouseEnter

MouseLeave

You would use:

http://wiki.roblox.com/index.php?title=API:Class/Mouse/Move

and possibly:

http://wiki.roblox.com/index.php?title=API:Class/Mouse/Idle
Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
09 Jul 2017 06:58 PM
I accidentally put mouse.Leave instead of mouse.Idle originally, my bad.
Report Abuse
UnRandomizing is not online. UnRandomizing
Joined: 20 Jun 2012
Total Posts: 1490
10 Jul 2017 02:03 PM
Oh, that makes sense now. Thanks.
Report Abuse
UnRandomizing is not online. UnRandomizing
Joined: 20 Jun 2012
Total Posts: 1490
11 Jul 2017 06:30 PM
I can't seem to get it to work. Could someone explain the flaw in the original coding?
Report Abuse
UnRandomizing is not online. UnRandomizing
Joined: 20 Jun 2012
Total Posts: 1490
11 Jul 2017 07:20 PM
Nevermind, I just created a 'for' loop to delete every SelectionBox inside all the ClickParts as a substitute for the end:

function DeleteSelections()
local Buildings = game.Workspace:GetChildren()
for i = 1, #Buildings do
if Buildings[i]:IsA("Model") then
local ClickPart = Buildings[i]:FindFirstChild("ClickPart")
if ClickPart then
local Selection = ClickPart:FindFirstChild("Selection")
if Selection then
Selection:Destroy()
end
end
end
end
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image