The model move script don't work

Hi,

So my goal is to when the player touch a part the script check the player coin’s value and if it’s more or eaquls 100 then a model will move to the other model. Like this:
https://gyazo.com/5189c72b438a44e15644c42f9d314971

Here’s the script:

local newisland = game.Workspace.Island1.Snow
local teleport = game.Workspace.Island1.Teleport
local price = 100
script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		if player.leaderstats.RoCoin.Value >= price then
			newisland:MoveTo(teleport.Position)
		end
	end
end)

Here how it looks like in the explorer:
Képernyőkép 2021-07-21 151704

And it’s not working, no errors in the output

If you have any suggestion let me know!

btw i just started scripting recently

If you walk on the part does it show you an error? Sometimes it will not give you an error if you don’t walk on the part. (From my experience)

Also I don’t think hit should be capitalized

1 Like

I would suggest using tweens instead of :MoveTo also on the wiki it talks about this: If there are any obstructions where the model is to be moved to, such as Terrain or other BasePart s, then the model will be moved up in the Y direction until there is nothing in the way. If this behavior is not desired, Model:SetPrimaryPartCFrame should be used instead.
which is basically it doesnt collide with other stuff so just use tweens

Check if the model is unanchored and use TweenService and SetPrimaryPartCFrame().

I think model:PivotTo(cframe) is better because you done need a primary parts for it.

Also possible, i just prefer SetPrimaryPartCFrame() because then you can also rotate the model. I didn’t really use PivotTo before so i didn’t think of that either haha.

1 Like

pivotto() takes cframe parameter so you can rotate it too but why i think its better is because you dont need primary part, and i kind of dont like setting a primary part just to cframe a model.

Ah ok, didn’t know about that. Thanks.

1 Like

So the model is move but…

The new script:

local newisland = game.Workspace.Island1.Snow
local newCFrame = CFrame.new(3316.758, 58.638, -4.826)
local price = 100
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player.leaderstats.RoCoin.Value >= price then
			newisland:PivotTo(newCFrame)
		end
	end
end)

when the player touch the part (with 100 coin) the script still doesn’t work
https://gyazo.com/e1f390b90d17257fb9152f640d302938

i know the model move because i tested it in an other script
the test script:

local newisland = game.Workspace.Island1.Snow
local newCFrame = CFrame.new(3316.758, 58.638, -4.826)
newisland:PivotTo(newCFrame)