|
| 15 May 2015 09:28 PM |
local Placing = false
script.Parent.Selected:connect(function(mouse) local Part = Instance.new("Part",workspace) Part.Anchored = true Part.Locked = false Part.Size = Vector3.new(4,4,4) Part.TopSurface = "Smooth" Part.BottomSurface = "Smooth" Part.BrickColor = BrickColor.new("Really red") Placing = true mouse.Button2Down:connect(function() Placing = false end) repeat wait() Part.Position = mouse.Hit.p + Vector3.new(0,Part.Size.Y/2,0) until Placing == false end)
Instead of just staying near the mouse, it floats closer to my head and then teleports back. Test this in play solo to find out. It also stop works after a min. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 15 May 2015 09:30 PM |
http://wiki.roblox.com/index.php?title=API:Class/Mouse/TargetFilter
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:33 PM |
local Placing = false
script.Parent.Selected:connect(function(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" local ReturnToStart = 0 local Part = Instance.new("Part",workspace) Part.Anchored = true Part.Locked = false Part.Size = Vector3.new(4,4,4) Part.TopSurface = "Smooth" Part.BottomSurface = "Smooth" Part.BrickColor = BrickColor.new("Really red") Placing = true mouse.Button2Down:connect(function() Placing = false end) repeat wait() mouse.TargetFilter = Part Part.Position = mouse.Hit.p + Vector3.new(0,Part.Size.Y/2,0) until Placing == false return ReturnToStart end)
Ok that works but now it doesnt return to start. So i can only place 1 block. And it isnt accurate placing. Man, i suk :( |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:40 PM |
I got this now and it works :D But problems: It doesn't move accurately. I would like to use 1 stud increments. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:40 PM |
Oops forgot to paste it o.O
local Placing = false
script.Parent.Selected:connect(function(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" local ReturnToStart = 0 local Part = Instance.new("Part",workspace) Part.Anchored = true Part.Locked = false Part.Size = Vector3.new(4,4,4) Part.TopSurface = "Smooth" Part.BottomSurface = "Smooth" Part.BrickColor = BrickColor.new("Really red") Part.Transparency = .5 local sBox = Instance.new("SelectionBox",Part) sBox.Adornee = Part sBox.Color = BrickColor.new("Institutional white") Placing = true mouse.Button1Down:connect(function() Placing = false end) repeat wait() mouse.TargetFilter = Part Part.Position = mouse.Hit.p + Vector3.new(0,Part.Size.Y/2,0) until Placing == false Part.Transparency = 0 sBox:Destroy() end) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:42 PM |
mouse.TargetFilter = Part
Why is this in the loop when you only need to set it once?
Also RenderStepped? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:43 PM |
| Ah yes. I will fix that. BUT I need to fix it with a 1 stud increment. Help? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:45 PM |
RunService broke my selection box lol.
But targetfilter is no longer in the loop. Also again, sorry to bother, but how do i do 1 stud increment? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:46 PM |
| What I was saying was it makes more sense to update the part position every frame(i.e. RunService.RenderStepped:wait() ) then to update it every 1/30 of a second(i.e. wait() ). |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:48 PM |
| Ok but 1 stud increment??? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:49 PM |
| I guess you would just have to round the position to the nearest stud or something? I don't know. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:49 PM |
| yes but how. I heard something about MouseIncrement before.. They supposedly released it. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:53 PM |
i have this function but then the script errors when i use
Round(mouse.Hit.P)
function Round(Amount) local Amount = tostring(Amount) local Decimal = string.find(Amount, ".",1,true) return Amount:sub(0,Decimal+1) end |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:54 PM |
function round(num, idp) return tonumber(string.format("%." .. (idp or 0) .. "f", num)) end |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:57 PM |
| And how do i use that function? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:59 PM |
It erroed when i did this
Round(mouse.Hit.p) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:01 PM |
It is used as follows: round(numberToRound, decimalToRoundTo)
For example: round(1.55, 1) -- Rounds to the first decimal place -- Output is 1.6(just as you'd expect.) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:05 PM |
| So how do i use it on mouse.Hit.p? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:08 PM |
This works, but doesnt round:
local Placing = false
function Round(num,idp) return tonumber(string.format("%."..(idp or 0).."f",num)) end
script.Parent.Selected:connect(function(mouse)
mouse.Icon = "rbxasset://textures\\GunCursor.png" local ReturnToStart = 0
Placing = true
mouse.Button1Down:connect(function() Placing = false end)
local CurrentBlock = script.Parent.CurrBlock.Value
local PartClone = script.Parent.Blocks[CurrentBlock]:Clone() PartClone.Parent = workspace
local sBox = Instance.new("SelectionBox",PartClone) sBox.Adornee = PartClone sBox.Color = BrickColor.new("Institutional white")
mouse.TargetFilter = PartClone
repeat wait() PartClone.Position = Vector3.new(Round(mouse.Hit.X,1),Round(mouse.Hit.Y,1),Round(mouse.Hit.Z,1)) + Vector3.new(0,PartClone.Size.Y/2,0) until Placing == false
sBox:Destroy() PartClone.Transparency = 0
end) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:09 PM |
| The round function takes a number value, not a userdata value. So you would have to round the value you are trying to set. |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 10:16 PM |
| Don't round to 1, round to 0. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:20 PM |
Umg yas thank you.
1 more question: I can only place one block at a time, and delete doesnt work.
Code:
local Placing = false
spawn(function() for i = 1,math.huge do Mode = script.Parent.Mode.Value wait() end end)
function Round(num,idp) return tonumber(string.format("%."..(idp or 0).."f",num)) end
script.Parent.Selected:connect(function(mouse)
if Mode == "Placing" then
mouse.Icon = "rbxasset://textures\\GunCursor.png" local ReturnToStart = 0
Placing = true
mouse.Button1Down:connect(function() Placing = false end)
local CurrentBlock = script.Parent.CurrBlock.Value
local PartClone = script.Parent.Blocks[CurrentBlock]:Clone() PartClone.Parent = workspace
local sBox = Instance.new("SelectionBox",PartClone) sBox.Adornee = PartClone sBox.Color = BrickColor.new("Institutional white")
mouse.TargetFilter = PartClone
repeat wait() PartClone.Position = Vector3.new(Round(mouse.Hit.X,0),Round(mouse.Hit.Y,0),Round(mouse.Hit.Z,0)) + Vector3.new(0,PartClone.Size.Y/2,0) until Placing == false
sBox:Destroy() PartClone.Transparency = 0
elseif Mode == "Deleting" then mouse.Button1Down:connect(function() local Target = mouse.Target if Target ~= nil and Target:IsA("BasePart") and Target.Locked == false then Target:Destroy() end end) end end) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:31 PM |
function round(num, idp) local num = num local idp = idp or 0 if type(num) ~= "number" then _,num = pcall(function() return num.Value end) or 0 end return tonumber(string.format("%." .. (idp or 0) .. "f", num)) end |
|
|
| Report Abuse |
|
|