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

i have this teleport code it doesn't work in roblox but it works in the play mode in roblox studio?

Asked by 7 years ago
Edited 7 years ago

script.Parent.Equipped:connect(function(mouse) local player = script.Parent.Parent.HumanoidRootPart mouse.Button1Down:connect(function() local mousePos = mouse.Hit player.CFrame = CFrame.new(mouse.Hit.p + Vector3.new(0,5,0)) -- this is where it doesn't work end) end)
0
So what is the error saying? Radstar1 270 — 7y
0
What does your error in output say? ChristianSenpaii 29 — 7y
0
there's no error in Roblox studio but in the published version there's a error orionater 0 — 7y

1 answer

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago
Edited 7 years ago

If this helped, please be sure to accept my answer :)

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait() -- Waits for character to add in workspace.
local Mouse = Player:GetMouse() -- Gets player's mouse.

script.Parent.Equipped:Connect(function()
    Mouse.Button1Down:Connect(function()
        local MousePos = Mouse.Hit -- You have made his variable and did no even use it, so lets use it on the line below.
        Character.PrimaryPart:SetPrimaryPartCFrame(MousePos.p + Vector3.new(0,5,0)) --The player does no have a CFrame, neither the Character. But, the Character has a PrimaryPart that has a CFrame.
-- this is where it doesn't work
    end)
end)
0
your code only has a error on the "SetPrimaryPartCFrame" orionater 0 — 7y
0
never mind i figured it out orionater 0 — 7y
Ad

Answer this question