Nenno
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 9208 |
|
|
| 03 Jan 2016 06:09 AM |
function Click(mouse) game.Workspace.Player.Instance.new("ForceField") end
function Unclick(mouse) game.Workspace.Player.Destroy("ForceField") end
function Select(mouse) mouse.Button1Down:connect(function() Click(mouse) end) mouse.Button1Up:connect(function() Unclick(mouse) end) end |
|
|
| Report Abuse |
|
|
eqis
|
  |
| Joined: 31 Dec 2008 |
| Total Posts: 295 |
|
|
| 03 Jan 2016 06:46 AM |
That's not how Instance works. You use new as a constructor. For example:
function Click(mouse) local forcefield = Instance.new("ForceField", workspace.Player) end
function Unclick(mouse) local forcefield = workspace.Player:FindFirstChild("ForceField") if forcefield then forcefield:Destroy() end end
|
|
|
| Report Abuse |
|
|
Egzekiel
|
  |
| Joined: 10 Jan 2011 |
| Total Posts: 1079 |
|
|
| 03 Jan 2016 06:48 AM |
You're not doing it right
local ff=Instance.new("ForceField",game.Workspace.Player) And game.Workspace.Player.ForceField:Destroy()
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 06:58 AM |
function Click(mouse) game.Workspace.Player.Instance.new("ForceField") --problematic end
function Unclick(mouse) game.Workspace.Player.Destroy("ForceField") --problematic end
function Select(mouse) mouse.Button1Down:connect(function() Click(mouse) end) mouse.Button1Up:connect(function() Unclick(mouse) end) end
Okay so for this line, what you don't understand is the concept of Roblox's hierarchy system. Game is like a folder. Game has another folder workspace in it. Workspace has many folders or objects such as parts and spawnpoints. Since you know the players name, that's great! In Roblox, they have given us libraries. Instance is one of those libraries. These libraries HOLD FUNCTIONS and FIELDS for you to modify or call(execute). Instance is an library and, since we use . to transverse through the 'folders', we do not use . to do this. game.Workspace.Player.Instance.new("ForceField") --problematic
Here is the correct way: local ForceField = Instance.new("ForceField") --new is a function inside the library Instance, which will set ForceField pointing to a new ForceField it creates ForceField.Parent = game.Workspace.Player --Parent is like a folder, but its a Field. It's something that holds like a number or something. In this case, it holds the parent of this part. So we tell that ForceField exists inside of the 'folder' game.Workspace.Player
Knowing all of this, this line should be much easier to modify. Destroy is a METHOD or FUNCTION inside of many instances which are created from the library Instance. Instances are objects that you can manipulate, such as Part, SpawnPoint, etc. game.Workspace.Player.Destroy("ForceField")
Should be used with : and you need to point to the actual forcefield. So you need to transverse through the player and select the ForceField object that was created using Instance. game.Workspace.Player.ForceField -- this is the force field you created. To destroy it, use the METHOD :Destroy()
game.Workspace.Player.ForceField:Destroy()
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 07:00 AM |
I have coded in c# Java but this is a little weird strange why it dosnt use brackets and semicolons.
But no mater what you are using you need to create a new instance of that object.
Same with parts in a scean. |
|
|
| Report Abuse |
|
|
Nenno
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 9208 |
|
| |
|
|
| 03 Jan 2016 07:03 AM |
"I have coded in c# Java but this is a little weird strange why it dosnt use brackets and semicolons.
But no mater what you are using you need to create a new instance of that object.
Same with parts in a scean."
Shut up |
|
|
| Report Abuse |
|
|