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

[SOLVED] Help Keeping Decal When Moving an Object with a Loop and CFrames?

I was creating an object that lies on a pedestal, and when pushed off by a player, it turns red and its face changes. Not long after, it begins to float and will face you. The problem, something without a face can't really face you.

My issue is just that, its face disappears the minutes it starts facing you. The worst part is, its not just an orientation issue. Its face doesn't exist on any of the six sides.

How can I fix this?

Here's my script:

local torso

game.Players.PlayerAdded:Connect(function(NewPlayer)
	NewPlayer.CharacterAdded:Connect(function(NewCharacter)
		torso = NewCharacter:WaitForChild('UpperTorso')
	end)
end)

script.Parent.Touched:Connect(function(TouchOther)
	local sr = script.Parent
	if TouchOther.Name == "Floor" then
		sr.Face.Transparency = 1
		sr.UglyFace.Transparency = 0
		sr.BrickColor = BrickColor.Red()
		sr.Groan.Playing = true
		game.Players.LocalPlayer.PlayerGui.WackyTune.Playing = false
		wait(2)
		sr.Groan.Playing = false
		wait(2.5)
		sr.Anchored = true
		sr.CanCollide = false
		for i = 1,10 do
			sr.CFrame = sr.CFrame + Vector3.new(0,0.1,0)
			wait()
		end
		wait(0.25)
		local srP = sr.CFrame.p
		while true do
			sr.CFrame = CFrame.new(srP, torso.Position)
			wait()
		end
	end
end)

4 comments

0

LocalPlayer is nil to the server. and CFrame.p is deprecated, you should be using CFrame.Position

0

So I changed line 27 to "local srP = sr.CFrame.Position. The decal still disappears when the object faces me. Do I need to assign a localplayer?

0

You could try a SurfaceGui. Not sure if that would help any better.

0

@Chexburger The SurfaceGUI didn't change it much either, but thanks for your input. Could anyone rewrite the script for me with the necessary corrections?

1 answer

I figured it out guys! I changed Line 27 to local srP = sr.CFrame.Position moved it into the loop.

Thanks for your help and support :)

Like this:

local torso

game.Players.PlayerAdded:Connect(function(NewPlayer)
	NewPlayer.CharacterAdded:Connect(function(NewCharacter)
		torso = NewCharacter:WaitForChild('UpperTorso')
	end)
end)

script.Parent.Touched:Connect(function(TouchOther)
	local sr = script.Parent
	if TouchOther.Name == "Floor" then
		sr.Face.Transparency = 1
		sr.UglyFace.Transparency = 0
		sr.BrickColor = BrickColor.Red()
		sr.Groan.Playing = true
		game.Players.LocalPlayer.PlayerGui.WackyTune.Playing = false
		wait(2)
		sr.Groan.Playing = false
		wait(2.5)
		sr.Anchored = true
		sr.CanCollide = false
		for i = 1,10 do
			sr.CFrame = sr.CFrame + Vector3.new(0,0.1,0)
			wait()
		end
		wait(0.25)
		while true do
			local srP = sr.CFrame.Position
			sr.CFrame = CFrame.new(srP, torso.Position)
			wait()
		end
	end
end)

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