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

Why doesn't this part move into lighting?

wait (0.5)
local player = game.Players.LocalPlayer
local money = player.leaderstats.Money

function onClicked(playerwhoclicked)
	money.Value = money.Value + 3
	script.Parent.Transparency = 0.1
	wait (0.1)
	script.Parent.Transparency = 0.3
	wait (0.1)
	script.Parent.Transparency = 0.5
	wait (0.1)
	script.Parent.Transparency = 0.7
	wait (0.1)
	script.Parent.Transparency = 0.9
	wait (0.1)
	script.Parent.Transparency = 1
	wait (0.1)
	script.Parent = game.Lighting
	wait (10)
	script.Parent = game.Workspace.WaterTree	
	wait (0.6)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

The parent is a part, inside a model. The script moves into Lighting by itself.. Please explain I have no idea whats wrong! It is in a Script

1 comment

0

Can you explain exactly what you're trying to do?

2 answers

✓ Accepted answer

It's actually really simple, you're moving the script into Lighting, not the parent. By saying "script.Parent = game.Lighting" you're saying that the script's new parent is lighting. To fix this, simply change it to "script.Parent.Parent = game.Lighting" and it is now will be moving the part instead of the script. I've gone ahead and edited the script to change this both when you moved the part into lighting, and back into the "WaterTree".

wait (0.5)
local player = game.Players.LocalPlayer
local money = player.leaderstats.Money

function onClicked(playerwhoclicked)
    money.Value = money.Value + 3
    script.Parent.Transparency = 0.1
    wait (0.1)
    script.Parent.Transparency = 0.3
    wait (0.1)
    script.Parent.Transparency = 0.5
    wait (0.1)
    script.Parent.Transparency = 0.7
    wait (0.1)
    script.Parent.Transparency = 0.9
    wait (0.1)
    script.Parent.Transparency = 1
    wait (0.1)
    script.Parent.Parent = game.Lighting
    wait (10)
    script.Parent.Parent = game.Workspace.WaterTree    
    wait (0.6)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Also if I were you, to not be confused by all these Parents, I would consider using a variable for the part, just to make things a bit cleaner.

wait (0.5)
local player = game.Players.LocalPlayer
local money = player.leaderstats.Money
local part = script.Parent
function onClicked(playerwhoclicked)
    money.Value = money.Value + 3
    part.Transparency = 0.1
    wait (0.1)
    part.Transparency = 0.3
    wait (0.1)
    part.Transparency = 0.5
    wait (0.1)
    part.Transparency = 0.7
    wait (0.1)
    part.Transparency = 0.9
    wait (0.1)
    part.Transparency = 1
    wait (0.1)
    part.Parent = game.Lighting
    wait (10)
    part.Parent = game.Workspace.WaterTree    
    wait (0.6)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

you set script.Parent = game.Lighting, wich places the script into the lighting. use script.Parent.Parent instead.

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