Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How can you insert a forcefield to a player's Torso?

Asked by 10 years ago

I am trying to make it so before the explosion is inserted into the game it gives the user of the tool a forcefield. the entire script is ok except the one line on inserting the FF. Here is the chunk of the script I am having problems with -

    local dir = (target - torso.Position) * Vector3.new(1, 0, 1)
    newBV = nil
    if dir.magnitude > .01 then 
        -- make 'em dash forwards too
        dir = dir.unit
        intance.new(ForceField).Character.Torso --This line is the one that is not working.
        newBV = Instance.new("BodyVelocity")
        newBV.P = 100000
        newBV.maxForce = Vector3.new(newBV.P, 0, newBV.P)
        newBV.velocity = dir * 50
        newBV.Parent = torso

        torso.CFrame = CFrame.new(torso.Position, target * Vector3.new(1, 0, 1) + Vector3.new(0, torso.Position.Y, 0))
    end

3 answers

Log in to vote
1
Answered by
DataStore 530 Moderation Voter
10 years ago

Change line six to the following:

Instance.new("ForceField", Character.Torso)

The second argument of Instance.new() enables you to "give it" a parent to which the object will be parented. The issue with what you were doing was the fact that you didn't spell "Instance" correctly. You were also not parenting it but rather attempting to get/use a property named "Character", which doesn't exist for the given object.

Also, in regards to the squiggly underlines, if you hover over a specific underlined item it will tell you the issue with it.

Ad
Log in to vote
1
Answered by 10 years ago

Instance.new() is how you can create any Instance.

Instance.new("Forcefield")

The above will create a forcefield, but it doesn't have a parent. To give it a parent you can use..

Instance.new("Forcefield", Character.Torso) -- Parents the 'Forcefield' to the Characters Torso

or

local forcefield = Instance.new("Forcefield") -- Creates a variable called forcefield and its value is the new 'Forcefield' Instance
forcefield.Parent = Character.Torso -- This parents the forcefield variable to Character.Torso

Either of the above will work.

So just change line 6 in your code to either of these, preferably the first one as its a bit easier to use and shorter.

If this helped then remember to rate +1 and accept answer for others who have problems with the same question.

  • NinjoOnline
Log in to vote
-5
Answered by 10 years ago

You misspelled Instance.new which might be the issue so change

intance.new(ForceField).Character.Torso

to

Instance.new("ForceField").Character.Torso
0
No it is still saying the line below it is wrong so it is still wrong noob1126 34 — 10y
0
What does it say in the Output? Also, I forgot to include quotes on ForceField. Darknesschaos 0 — 10y
0
For this, it would be: Instance.new("ForceField", Character.Torso) Pawsability 65 — 10y

Answer this question