I’m trying to create a very simple script that inserts a LocalScript into the player’s character. For some other miscellaneous reasons, it can’t be put straight into StarterCharacterScripts.
local part = script.Parent
local localScript = part.ForceFirstPerson
part.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
if player:FindFirstChild("ForceFirstPerson") ~= nil then return end
local newLocalScript = localScript:Clone()
newLocalScript.Parent = player.Character
newLocalScript.Enabled = true
end
end)
I’ve determined that the issue with this script would seem to be the :FindFirstChild() statement, unless I am mistaken. For context, this is in a regular script. When you touch the part, it skips over the :FindFirstChild() and duplicates a bajillion local scripts.
My main question is that can anybody help me get to the root of this problem, or find a workaround?