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

I am getting an error code when running this script. What is incorrect?

Asked by 3 years ago
local mps = game:GetService("MarketplaceService")
local button = script.Parent
local gamePassID = 18411129
local AnotherBrick = game.Workspace.winners

button.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
            if mps:PlayerOwnsAsset(player, gamePassID) then
                print("Player has pass.")
                player:MoveTo(AnotherBrick.Position) -- 5
            end
        end
    end
end)
0
Whats the error code AlexanderYar 788 — 3y
0
Please mark my answer as correct if it works plsss AlexanderYar 788 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Your problem is probably you trying to use :MoveTo on a player instance.

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

Player is player instance and

  player:MoveTo(AnotherBrick.Position) -- 5

Won't work. To fix it, move the players character humanoid o think it is, if it's not the humanoid then it's the character.

player.Character.Humanoid:MoveTo(AnotherBrick.CFrame)
0
thx dude miner561473 17 — 3y
0
thE lEmON mAdE mE dO iT AlexanderYar 788 — 2y
Ad

Answer this question