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 » Scripting Helpers
Home Search
 

Re: CanCollide Tool

Previous Thread :: Next Thread 
gamer961 is not online. gamer961
Joined: 20 Jul 2011
Total Posts: 800
26 Dec 2012 10:56 AM
Okay, so, I'm trying to make a CanCollide tool that only works if it is your brick. It DOESN'T work if it is a brick not called SpawnPart, if it isn't yours, or if you just didn't make it yours. You see, you have to clone the brick "Spawn Part" before you can manipulate it with my other tools. ANYWAYS....
I can't find out what's wrong with the script, please help me.

wait(0.1)

active = false

selectionBox = Instance.new("SelectionBox")
selectionBox.Color = BrickColor.new("Bright blue")
selectionBox.Transperency = .7
selectionBox.Visible = true

selectionLasso = Instance.new("SelectionPartLasso")
selectionLasso.Color = BrickColor.Black()
selectionLasso.Humanoid = game.Players.LocalPlayer.Character.Humanoid

gui = Instance.new("ScreenGui")
text = Instance.new("TextLabel")
text.Parent = gui
text.Text = "No brick selected"
text.BackgroundColor3 = Color3.new(1/256*17, 1/256*17, 1/256*17)
text.BorderColor3 = Color3.new(1/256*17, 1/256*17, 1/256*17)
text.TextColor3 = Color3.new(1, 1, 1)
text.Position = UDim2.new(0, 0, 1, -20)
text.Size = UDim2.new(0, 100, 0, 20)
text.BackgroundTransparency = 0.25

function onMouseButton1Down(target)
if target ~= nil then
if target.Locked == false then
function onButton1Down(mouse)
local player = game.Players.LocalPlayer
local character = player.Character
if mouse.Target ~= nil then
if (mouse.Target.Name == "SpawnPart"
or mouse.Target.Name == player.Name) then
if (mouse.Target.Locked == true) then return end
if target.CanCollide == true then
target.CanCollide = false
selectionBox.Color = BrickColor.Red()
text.Text = "Brick doesn't collide"
else
target.CanCollide = true
selectionBox.Color = BrickColor.Green()
text.Text = "Brick collides"
end
end
end
end

function onMouseMoved(target)
if target ~= nil then
if target.Locked == false then
if target.CanCollide == true then
selectionBox.Adornee = target
selectionBox.Color = BrickColor.Green()
selectionLasso.Part = target
text.Text = "Brick collides"
else
selectionBox.Adornee = target
selectionBox.Color = BrickColor.Red()
selectionLasso.Part = target
text.Text = "Brick doesn't collide"
end
else
selectionBox.Adornee = nil
selectionLasso.Part = nil
text.Text = "Brick is locked!"
end
else
selectionBox.Adornee = nil
selectionLasso.Part = nil
text.Text = "No brick selected"
end
end

function onSelected(mouse)
if active == false then
active = true
gui.Parent = game.Players.LocalPlayer.PlayerGui
selectionBox.Parent = game.Players.LocalPlayer.PlayerGui
selectionLasso.Parent = game.Players.LocalPlayer.PlayerGui
mouse.Move:connect(function() onMouseMoved(mouse.Target) end)
mouse.Button1Down:connect(function() onMouseButton1Down(mouse.Target) end)
end
end

function onDeselected()
if active == true then
active = false
gui.Parent = nil
selectionBox.Parent = nil
selectionLasso.Parent = nil
end
end

script.Parent.Selected:connect(onSelected)
script.Parent.Deselected:connect(onDeselected)
Report Abuse
gamer961 is not online. gamer961
Joined: 20 Jul 2011
Total Posts: 800
26 Dec 2012 10:56 AM
Clone the brick "SpawnPart"*
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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