Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Teleport player using click detector?

Im trying to make a door, and when you click on the handle it teleports you inside the room

> function onClicked(plr)

if plr.Name == "Bylli_Oruze" or plr.Name == script.Parent.Parent.Parent.CurrentOwner.Value then

game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.In.Position)

  

end

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
  • "In" is a little part on the other side of the door that represents where the player should be moved to (There is also an "Out" part on the outside of the door for when the player wants to leave the room)

  • the "If plr.Name" Part is for the house script im trying to make, i put my name as the creator should have access to all the houses no matter what

im not sure where i went wrong

2 answers

✓ Accepted answer

The part is in workspace right?If it is then the script has to be a server script/normal script because localscripts don't work in workspace and a server script can't do game.Players.LocalPlayer but you have the local player through an argument, why don't you use that

4 comments

0

Its a normal script, but i really dont understand what to do

0

ive tried plr.Character etc but that didnt work, ive tried plr.HumanoidRootPart etc but that didnt work either, so im pretty much stuck

0

use playeradded events on player service

0

^not a clue what that means

after a few lost brain cells and some research i got this:

debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function(player)

if not debounce then

debounce = true

local char = player.Character

if player.Name == "Bylli_Oruze" or player.Name == script.Parent.Parent.Parent.CurrentOwner.Value then

script.Parent.Parent.WoodPart.Open:Play()

char.HumanoidRootPart.CFrame = CFrame.new(112.295, 5.67, -97.05)

script.Parent.Parent.Parent.Buzzer.Indi.BrickColor = BrickColor.new("Pastel blue-green")

wait(2)

script.Parent.Parent.Parent.Buzzer.Indi.BrickColor = BrickColor.new("Persimmon")

wait(1)

debounce = false

end

end

end)

thanks for the help anyway, il accept the answer above

This discussion is preserved as it was. New answers, comments, and votes are closed.