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

Need help with local parts when cloning a meshpart, what is wrong? (SOLVED)

Asked by
xsodar 19
5 years ago
Edited 5 years ago

I have a problem when I clone my meshpart from lighting to workspace, then all the scripts in my meshpart just stop working.

The thing is that I want to make a meshpart that only disappear for the person who touches it. So I made a localscript in "StarterGui"

local part = game.Lighting.DiamondGem:Clone()

part.Parent = game.Workspace.CurrentCamera

The cloning works but not my other scripts that are in the meshpart (DiamondGem). The scripts in my meshpart is just normal scripts.

Here is one of the scripts:

collect = true

game.Workspace.DiamondGem.Touched:Connect(function(hit)

    local humanoid = hit.Parent:FindFirstChild("Humanoid")

    if humanoid ~= nil and collect == true then
        collect = false

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)


    wait(0.2)
    game.Workspace.DiamondGem.Transparency = 1

    wait()
    player.leaderstats.Diamond.Value = player.leaderstats.Diamond.Value + 1
    wait(10)
    game.Workspace.DiamondGem.Transparency = 0.4
    collect = true

    end
end)

This script works when I'm not using "Clone". But when I do this stops working. Anyone knows how to fix this?

Thanks

1
Don't use Lighting as storage - that's not what it's for. SummerEquinox 643 — 5y

Answer this question