I have a part that when the player touches it, the part sends an event that triggers another script. The script teleports the player so that he cannot reactivate the part by hitting it again. I have problems with teleporting the player, please help. The script is down below:
The script
local player = game.Players.LocalPlayer
local OpenMenuEvent = game:GetService("ReplicatedStorage"):WaitForChild("CarMechanicJob1").OpenJobGUI
local CloseMenuEvent = game:GetService("ReplicatedStorage"):WaitForChild("CarMechanicJob1").CloseJobGUI
OpenMenuEvent.Event:Connect(function(player)
local RootPart = player:FindFirstChild("HumanoidRoot")
RootPart.CFrame = CFrame.new(-30.605, 4.221, 1256.933) ---Problematic line... (7)
workspace.CurrentCamera.CameraType = "Scriptable"
workspace.CurrentCamera.CFrame = workspace.CarMechanicJob1.JobCamera.CFrame
script.Parent.Visible = true
end)
HumanoidRootPart is child of Character, not Player
There is no such thing âHumanoidRootâ in the player. It has âHumanoidRootPartâ inside the character, not the player.
Great solution! Works flawlessly! Is there a way I can add a cooldown that will make the part not work when touched for like (example) 10 seconds from the first time a player touches it? Whenever I touch it, it just goes wild with about 100+ touches.
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local humrp = char:WaitForChild("HumanoidRootPart")
normal script in serverscriptservices:
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local humrp = char:WaitForChild("HumanoidRootPart")
end)