Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can i get help with this cloning problem?

I cant get this forcefield Union to be a part of the players torso, but it wont work... help? i put this in the players starter inventory but it still wont work

FF = ReplicatedStorage.FORCE
local playr = game.Players.LocalPlayer
local mouse = playr:GetMouse()
local uis = game:GetService("UserInputService")
local animationTrack = playr.Character.Humanoid:LoadAnimation(animation)

function FFON(key,gp)
    if key.KeyCode == Enum.KeyCode.F and gp == false then 
        local clone = FF:Clone()
		FF.parent = playr.torso XYZ position
    end
end

uis.InputBegan:connect(FFON)

function forcefieldoff(key)
    if key.KeyCode == Enum.KeyCode.F and gp == false then
    	playr.torso:findFirstChild(FORCE)
        if found then
		playr.torso.FORCE:Destroy()
end
    end
end

uis.InputEnded:connect(forcefieldoff)

1 answer

Problem:

Torso is not a member of Player. Forgot the Variable for found. ForceFields' parented under Player

Solution:

First of all, in order to make a ForceField show up on the Character you would have to place it just in the Character. Not the Torso, not the Head or anything of that sort. Just in the Character. So you would change your ForceField's parent to the Character. Something like this:

FF.Parent = playr.Character -- This will call on the Character which contains the torso, head, arms, legs and basically, the whole avatar. 

You would do the same for the second code block if you are searching for the ForceField then you would change the script and do the following:

local found = playr.Character:findFirstChild("FORCE") -- You also forgot to make found a variable for the ForceField.
if found then -- If Statement checking for ForceField inside of Character.
--code
end

I hope I helped, thank you for using your time to read my answer. Have a nice day!

~~ KingLoneCat

This discussion is preserved as it was. New answers, comments, and votes are closed.