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

Material of the "Part" (Made by the script) not changing?

Asked by 4 years ago

So, i created a "Part" with a script:

local clickdetector = script.Parent:WaitForChild("ClickDetector")

clickdetector.MouseClick:Connect(function()
    game.Workspace.MEDIUM2.Transparency = 1
    game.Workspace.MEDIUM2.Position = Vector3.new(0,0,0)
    local part = Instance.new("Part")
    part.Position = Vector3.new(0,0,0)
    part.Name = "COLORCHANGE"
    part.Parent = game.Workspace
    part.Size = Vector3.new(100,100,100)
    wait(3)
    game.Workspace.MEDIUM2.Transparency = 0
    game.Workspace.MEDIUM2.Position = Vector3.new(121.199, 100, -309.035)
end)

And when i try to modify the Material of the "COLORCHANGE" it doesn't works. The script:

local clickdetector = script.Parent:WaitForChild("ClickDetector")

clickdetector.MouseClick:Connect(function()
    game.Workspace.Medium3.Transparency = 1
    game.Workspace.Medium3.Position = Vector3.new(0,0,0)
        part = game.Workspace.COLORCHANGE
        part.Material="Neon"
    game.Workspace.Medium3.Transparency = 0
    game.Workspace.Medium3.Position = Vector3.new(98.199, 100, -309.035)
end)

Why is the script not working?

0
are these two totally separate scripts inside the same part? BlueTaslem 18071 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Here's one way to do it, I think this might help you a little.

local clickdetector = script.Parent:WaitForChild("ClickDetector")

clickdetector.MouseClick:Connect(function()
    script.Parent.Material = Enum.Material.Neon
end)
Ad

Answer this question