|
| 20 May 2014 06:59 PM |
Ok This scrip is for a tool i made its just a normal tool block and i added this script to it.
I have not scripted in years so i'm very rusty so please bare with me if i do something stupid or if things have changed. This script should basically when you press the letter "t" while the tool is equipped it will place a black block then a orange block and then black and then orange and so on just by spamming the k button. Then when you press the letter "y" it will remove all the blocks named "Tape O" and "Tape B". The blocks will be spawned in the players head whom is using the tool. Then when you press the key "U" you can make those blocks named "Tape O" and "Tape B" have cancollide true and the the key "I" will make it so that they are not cancollide so the player using the tool can switch it on and off to whether it is cancollide or not. Please help me fix this thanks:D
--by TreeLineUser
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(T)
local T= Instance.new('Part',game:GetService'Workspace') t.Size=Vector3.new(1,1,1) t.Anchored=true t.CFrame=game:GetService'Players'.LocalPlayer.Character:FindFirstChild'Head'.CFrame t.Transparency=.4 t.BrickColor.new'Black' t.Name = "Tape B" wait(1) t.BrickColor.new'Bright Orange' t.Name = "Tape O" t.CanCollide = false wait(0.1)
mouse.KeyDown:connect(function(Y) game.Workspace.Tape B:remove() game.Workspace.Tape O:remove()
mouse.KeyDown:connect(function(U) game.Workspace.Tape B.CanCollide = true game.Workspace.Tape O.CanCollide = true
mouse.KeyDown:connect(function(I) game.Workspace.Tape B.CanCollide = false game.Workspace.Tape O.CanCollide = false end end end end |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 07:01 PM |
The 'Tape B' and 'O' must be in quotations.
game.Workspace.Tape B -- Wrong.
game.Workspace['Tape B'].CanCollide = false -- Correct.
game.Workspace:FindFirstChild('Tape B').CanCollide = false -- Correct. |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 07:03 PM |
What's the difference between using game.Workspace['Tape B'].CanCollide = false -- Correct. and using game.Workspace:FindFirstChild('Tape B').CanCollide = false -- Correct. |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 07:05 PM |
| FindFirstChild('') will also see if it is nil, or does not exist. |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 07:07 PM |
| Ok but technically it wont make a difference right? |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 07:15 PM |
Ok i got this now but still not working.
--by TreeLineUser
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(T)
local T= Instance.new('Part',game:GetService'Workspace') t.Size=Vector3.new(1,1,1) t.Anchored=true t.CFrame=game:GetService'Players'.LocalPlayer.Character:FindFirstChild'Head'.CFrame t.Transparency=.4 t.BrickColor.new'Black' t.Name = 'Tape B' wait(1) t.BrickColor.new'Bright Orange' t.Name = 'Tape O' t.CanCollide = false wait(0.1)
mouse.KeyDown:connect(function(Y) game.Workspace.Tape B:remove() game.Workspace.Tape O:remove()
mouse.KeyDown:connect(function(U) game.Workspace['Tape B'].CanCollide = true game.Workspace['Tape 0'].CanCollide = true
mouse.KeyDown:connect(function(I) game.Workspace['Tape B'].CanCollide = false game.Workspace['Tape 0'].CanCollide = false end end end end |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 07:20 PM |
| You did not fix everything with a space, and you are using 'Tape 0' instead of 'Tape O'(letter v. number). |
|
|
| Report Abuse |
|
|
|
| 20 May 2014 07:23 PM |
| By the way, you set up the mouse and keyboard connections wrong. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
bradz234
|
  |
| Joined: 02 Aug 2009 |
| Total Posts: 31 |
|
|
| 22 May 2014 06:30 AM |
Should be something like:
mouse.KeyDown:connect(function(key) if key == "o" then --code elseif key == "t" then --code end end) |
|
|
| Report Abuse |
|
|
|
| 22 May 2014 04:30 PM |
So this? mouse.KeyDown:connect(function(key) if key == "o" then --code game.Workspace.Tape B:remove() game.Workspace.Tape O:remove() elseif key == "t" then --code local T= Instance.new('Part',game:GetService'Workspace') t.Size=Vector3.new(1,1,1) t.Anchored=true t.CFrame=game:GetService'Players'.LocalPlayer.Character:FindFirstChild'Head'.CFrame t.Transparency=.4 t.BrickColor.new'Black' t.Name = 'Tape B' wait(1) t.BrickColor.new'Bright Orange' t.Name = 'Tape O' t.CanCollide = false end end) |
|
|
| Report Abuse |
|
|
| |
|
bradz234
|
  |
| Joined: 02 Aug 2009 |
| Total Posts: 31 |
|
|
| 23 May 2014 12:08 AM |
| Sorry for this late reply. Anyways, I am unsure of what you want to do here, so please refer to: http://wiki.roblox.com/index.php/Taking_keyboard_input |
|
|
| Report Abuse |
|
|
|
| 23 May 2014 10:47 AM |
| I'm wanting it to work as a tool that does those things when i press that key while having the tool equipped |
|
|
| Report Abuse |
|
|
|
| 23 May 2014 10:57 PM |
Thank you for the link, Ok so would this work or no? I made it more basic not as many options but if i can get this to work i'm confident i can add the other functions to it as well.
local tool = script.Parent tool.Selected:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "y" then local T= Instance.new('Part',game:GetService'Workspace') t.Size=Vector3.new(1,1,1) t.Anchored=true t.CFrame=game:GetService'Players'.LocalPlayer.Character:FindFirstChild'Head'.CFrame t.Transparency= 0 t.BrickColor.new'Black' t.Name = 'Tape' t.CanCollide = false elseif key == "t" then game.Workspace.Tape:remove() end end) end) |
|
|
| Report Abuse |
|
|
|
| 23 May 2014 10:59 PM |
local tool = script.Parent tool.Selected:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "y" then local t= Instance.new('Part',game:GetService'Workspace') t.Size=Vector3.new(1,1,1) t.Anchored=true t.CFrame=game:GetService'Players'.LocalPlayer.Character:FindFirstChild'Head'.CFrame t.Transparency= 0 t.BrickColor.new'Black' t.Name = 'Tape' t.CanCollide = false elseif key == "t" then game.Workspace.Tape:remove() end end) end) |
|
|
| Report Abuse |
|
|
| |
|