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: How do you identify the part you click using...

Previous Thread :: Next Thread 
darkwisp is not online. darkwisp
Joined: 07 Apr 2010
Total Posts: 22653
29 Jun 2014 02:30 AM
The property, mouse.hit

SO far Wherever I click, the brick spawns, but I want it to snap unto the part I click on.

This is just part of it
=====

lifetime = 2 -- how long the boulder stays there. 5 is a good value.
player = game.Players.LocalPlayer
function onButton1Down(mouse)
if mouse.Target~=nil then
local hit = mouse.Target
local body = game.Players.LocalPlayer.Character:findFirstChild("Torso")
if mouse.Target.ClassName == "Part" and (hit~=nil) and body.Position.x - hit.Position.x < 30 and body.Position.x - hit.Position.x > -30 and body.Position.y - hit.Position.y < 30 and body.Position.y - hit.Position.y > -30 and body.Position.z - hit.Position.z < 30 and body.Position.z - hit.Position.z > -30 then
if player.Character.Energy.Value >= 5 then

if game.Workspace.DefenderTeamTurn.Value == true then
if player.TeamColor == BrickColor.new("Bright violet") then
player.Character.Energy.Value = player.Character.Energy.Value - 5
local b = Instance.new("Part")
b.BrickColor = BrickColor.new("Bright violet")
b.Position = mouse.Hit.p
b.Size = Vector3.new(5, 5, 5)
b.Shape = 1
b.Anchored = true
b.Parent = game.Workspace
b.CanCollide = false

local new_script = script.Parent.Damage:clone()
new_script.Disabled = false
new_script.Parent = b

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = b


--b.Velocity = (script.Parent.Parent.Parent.Character.Head.Position - mouse.Hit.p).unit * -50 + Vector3.new(0, 10, 0)
b.CFrame = CFrame.new(mouse.Target.Position)
game:GetService("Debris"):AddItem(b, lifetime)
end
end

But seriously, join The Collision.
Report Abuse
darkwisp is not online. darkwisp
Joined: 07 Apr 2010
Total Posts: 22653
29 Jun 2014 02:32 AM
Oops, not the mouse.hit property

I mean the mouse.Target property.

But seriously, join The Collision.
Report Abuse
darkwisp is not online. darkwisp
Joined: 07 Apr 2010
Total Posts: 22653
29 Jun 2014 02:38 AM
nvm, figured it out myself

But seriously, join The Collision.
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