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)
✓ ANSWER ACCEPTED
i have this teleport code it doesn't work in roblox but it works in the play mode in roblox studio?
1 answer
✓ Accepted answer
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)
2 comments
0
your code only has a error on the "SetPrimaryPartCFrame"
0
never mind i figured it out
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
So what is the error saying?
What does your error in output say?
there's no error in Roblox studio but in the published version there's a error