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

How to move Primary Part Cframe to scripts parent's Position?

Asked by 3 years ago

I am making a brick and when that brick is hovered over with a mouse a transparent copy of what they want to build pops up. However when I try to add a Primary Part Cframe to the model it only responds to numbers such as "2, 3, -5" and not something like script.Parent.Position. Any help would be appreciated.

local newPosition = script.Parent.Position
local archerT = false
local WarriorT = false

while true do
    wait(0.001)
    script.Parent.ClickDetector.MouseHoverEnter:Connect(function()
        if game.Workspace.Data.Buildingname.Value == ("ArcherHut") then
            archerT = true
        elseif game.Workspace.Data.Buildingname.Value == ("WarriorCamp") then
            WarriorT = true
        end

    end)

    script.Parent.ClickDetector.MouseHoverLeave:Connect(function()
        archerT = false
        WarriorT = false
    end)
    if archerT == true then
        game.Workspace.ArcherCampTrans:SetPrimaryPartCFrame(newPosition)
    elseif WarriorT == true then
        game.Workspace.WarriorCamptrans:SetPrimaryPartCFrame(newPosition)
    end
    if archerT == false then
        game.Workspace.ArcherCampTrans:SetPrimaryPartCFrame(CFrame.new(-102.6, 46.61, -1152.1))
    elseif WarriorT == false then
        game.Workspace.WarriorCamptrans:SetPrimaryPartCFrame(CFrame.new(-124.258, 45.91, -1031.304))
    end
end

1 answer

Log in to vote
0
Answered by 3 years ago

Sorry Guys, I figured it out. All you have to do is add a (Cframe.new(Script.Parent.Position)). Instead of just (Script.Parent.Position).

Ad

Answer this question