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

Position Change not working?

Asked by 8 years ago

I'm trying to make it when a mouse is hovered over a part, the script moves a part called "factoryFaded" from ServerStorage to Workspace, and bring its to the coordinates (-25.222, -0.49, -0.554). It isn't working, and the only output I get says "factoryFaded is not a valid member of Part", and "factoryFaded is not a valid member of ServerStorage"

Here is the script

local click = script.Parent

while wait(0.5) do

    click.MouseHoverEnter:connect(function(player) 
        game.ServerStorage.factoryFaded.Parent = game.Workspace
        game.Workspace.factoryFaded.Position = Vector3.new(-25.222, -0.49, -0.554)
    end)
    click.MouseHoverLeave:connect(function(player)
        game.Workspace.factoryFaded.Parent = game.ServerStorage
    end)
    click.MouseClick:connect(function(player)

    end)
end

0
Change Position to CFrame and is the Script a LocalScript? GeezuzFusion 200 — 8y

1 answer

Log in to vote
0
Answered by
DevSean 270 Moderation Voter
8 years ago

You don't want a while loop as this will keep creating connections which will result in the functions being called multiple times. (Therefore attempting to move the part multiple times resulting in an error).

It's also better to save what you're changing as a variable and manipulate it that way.

local click = script.Parent
local factoryFade = game.ServerStorage.factoryFaded

click.MouseHoverEnter:connect(function(player) 
    factoryFade.Parent = workspace
    -- Now that you have told me factoryFade is a model you have two options:

    --factoryFade:MoveTo(Vector3.new(-25.222, -0.49, -0.554))
    --or (if you've set factoryFade.PrimaryPart)
    --factoryFade:SetPrimaryPartCFrame(CFrame.new(-25.222, -0.49, -0.554))
end)

click.MouseHoverLeave:connect(function(player)
    factoryFade.Parent = game.ServerStorage
end)

click.MouseClick:connect(function(player)

end)
0
I tried using that, and the output said : "11:25:11.597 - Position is not a valid member of Model 11:25:11.598 - Script 'Workspace.tile1.ClickDetector.Script', Line 6 KennySfromTitan 106 — 8y
0
There's your problem, factoryFade is a model and therefore doesn't have a position property, I've edited the script for you. DevSean 270 — 8y
Ad

Answer this question