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