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

Teleport player using click detector?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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

0
Its a normal script, but i really dont understand what to do Bylli_Oruze 38 — 5y
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 Bylli_Oruze 38 — 5y
0
use playeradded events on player service LoganboyInCO 150 — 5y
0
^not a clue what that means Bylli_Oruze 38 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question