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

Part staying in lighting?

I'm trying to have my puck respawn to center ice which is puckspawn but It just stays in lighting.

_G.ResetPuck = function()
	    local newP = game.Lighting.Puck
	    newP:Clone().Parent = game.Workspace
		newP.CFrame = game.Workspace.PuckSpawn.CFrame
		newP.Anchored = true
		vals.IsFO.Value = true
		if game.Workspace:FindFirstChild("GoalPuck") ~= nil then
			workspace.GoalPuck:Destroy()
		end
		if CheckTeam(game.Teams.Away.TeamColor) == false then gfo.Away.Value = true end
		if CheckTeam(game.Teams.Home.TeamColor) == false then gfo.Home.Value = true end
		while gfo.Away.Value == false do wait() end
		while gfo.Home.Value == false do wait() end
		newP.Parent = game.Workspace
		gfo.Away.Value = false
		gfo.Home.Value = false
		vals.IsFO.Value = false
		newP.Anchored = false
end

**

1 comment

0

Never use _G. Use a Module Script.

1 answer

✓ Accepted answer

The clone of the puck is in the Workspace, but what you're actually doing is assigning the original puck's CFrame to the puck spawnpoint and anchoring the original puck. Your goal is to evidently edit the clone's Anchored and CFrame properties.

The fix is as simple as creating a variable for the clone, such as...

local clone = newP:Clone() -- or similar; if you wanted newP to be the clone you need to call Clone() on the original puck not assigned to a variable

...and then assign the desired property changes to the clone.

1 comment

0

Should I change the name of it to?

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