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

Parts touch interest isn't working when cloned, why?

Asked by 2 years ago

The generator has a touch function that activates the gen, however it seems the gen isn't detecting hits, i don't know why, it has nothing to do with the gen itself because when i pull the gen out of storage and test it in the lobby it activates fine. Script for the gen touch interest:

script.Parent.ActivationField.Touched:connect(function(plr)
    script.Parent.ActivationField:Destroy()
    script.Parent.Light.Enabled = true
    script.Parent.Signal.BillboardGui.Enabled = true
    script.Parent.Repair:Play()
    wait(4)
    game.ReplicatedStorage.Stage.Value = game.ReplicatedStorage.Stage.Value - 1
    game.ReplicatedStorage.Gen:FireAllClients(game.ReplicatedStorage.Stage.Value)
    script.Parent.Sound.MaxDistance = 50
    script.Parent.Signal.BillboardGui.Enabled = false
    script.Parent.Finished:Play()

end)

part of the Main Script that spreads the gens across map:

 function Gens()

    local Folder = map:WaitForChild("Gens")
    local Generators = Folder:GetChildren()

    local gen = game.ReplicatedStorage.Generator
    local gen_count = 0
    while gen_count < 8 do
        gen_count = gen_count + 1
        local gen_spawned = Generators[math.random(1, #Generators)]
        local New_Gen = gen:Clone()
        New_Gen.Name = ("Gen ".. gen_count)
        New_Gen.Parent = map
        New_Gen.Position = gen_spawned.Position + Vector3.new(0,3,0)
        print(New_Gen.Name, New_Gen.Position)
    end

end

Note: I have already tried server storage for a storage location, it hasn't fixed it.

Answer this question