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

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

Asked by 5 years ago
Edited 5 years ago

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)
0
LocalPlayer is nil to the server. and CFrame.p is deprecated, you should be using CFrame.Position User#19524 175 — 5y
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? ZeroNoey 19 — 5y
0
You could try a SurfaceGui. Not sure if that would help any better. chexburger 358 — 5y
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? ZeroNoey 19 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
Ad

Answer this question