Can anyone help me with this?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make elevator system like in Doors

  2. What is the issue? My system works perfectly but the problem is that when i play with my friend and he touches the elevator trigger, i cant go into elevator, it makes trigger cantouch false to whole server for some reason when i pass note to client, but when i go to roblox studio on current server it says cantouch is true when im inside elevator (and for me its cantouch false)

  3. What solutions have you tried so far? I tried to make part untouchable through local script but it doesnt for some reason work and some free models scripts, but their scripts are confusing

Here is my script for the elevator

local TweenService = game:GetService("TweenService")
local fastpart = script.Parent.ElevatorFastPart1 -- Assuming the LocalScript is directly under the Part
local slowpart = script.Parent.ElevatorSlowPart1

-- Define the starting position and target position
local startPos = fastpart.Position
local targetPos = Vector3.new(43.65, 5.9, 3.7)
local targetPos2 = Vector3.new(38.55, 5.9, 3.7)

-- Define the properties of the tweens
local tweenInfo = TweenInfo.new(
	2, -- Duration
	Enum.EasingStyle.Sine, -- Easing style
	Enum.EasingDirection.Out, -- Easing direction
	0, -- Number of times to repeat (-1 means infinite)
	false, -- Reverses on repeat
	0 -- Delay between loops
)

-- Create the tweens
local tweenToTarget = TweenService:Create(fastpart, tweenInfo, {Position = targetPos})
local tweenToTarget2 = TweenService:Create(slowpart, tweenInfo, {Position = targetPos2})
local tweenToStart = TweenService:Create(fastpart, tweenInfo, {Position = startPos})
local tweenToStart2 = TweenService:Create(slowpart, tweenInfo, {Position = startPos})

local startval = 0 -- number of players

local isinElevator = false

script.Parent.Hitbox1.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		if  not isinElevator and startval < 8 then
			isinElevator = true
			startval = startval + 1
			player.Character.Torso.CFrame = script.Parent.TPPartEnt.CFrame
			script.Parent.Hitbox1.SurfaceGui.TextLabel.Text = tostring(startval) .. "/8 Players"
			game.ReplicatedStorage.InsideElevator2:FireClient(player) -- the event that fires for leave button to be visible only and sets trigger to cantouch false to client 
		end
	end
end)

game.ReplicatedStorage.LeavingElevator2.OnServerEvent:Connect(function(player)
	isinElevator = false
	startval = startval - 1
	player.Character.Torso.CFrame = script.Parent.TPPartLeft.CFrame
	script.Parent.Hitbox1.SurfaceGui.TextLabel.Text = tostring(startval) .. "/8 Players"
end)

local intermission = 15

while true do -- loop that will make elevator continously close door and open
	script.Parent.Hitbox1.SurfaceGui.Intermission.Text = "Intermission..."
	script.Parent.Hitbox1.CanTouch = false
	tweenToTarget:Play()
	tweenToTarget2:Play()
	wait(2)
	intermission = 16
	script.Parent.TeleportTrigger2Left.Script.Enabled = true
	wait(1)
	script.Parent.TeleportTrigger2Left.Script.Enabled = false
	wait(2)
	tweenToStart:Play()
	tweenToStart2:Play()
	wait(2)
	startval = 0
	script.Parent.Hitbox1.SurfaceGui.TextLabel.Text = tostring(startval) .. "/8 Players"
	script.Parent.Hitbox1.CanTouch = true
	for i = 1,16 do
		intermission = intermission - 1
		script.Parent.Hitbox1.SurfaceGui.Intermission.Text = tostring(intermission)
		wait(1)
	end
end

Here is script for the “Leave” button

local TS = game:GetService("TweenService")
local ti = TweenInfo.new(.7, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

game.ReplicatedStorage.InsideElevator2.OnClientEvent:Connect(function()
	workspace.ElevatorDoor2.Hitbox1.CanTouch = false
	workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	TS:Create(workspace.CurrentCamera, ti, {CFrame = workspace.ElevatorDoor2.Camera.CFrame}):Play()
	wait(.7)
	script.Parent.Visible = true
end)

script.Parent.MouseButton1Click:Connect(function()
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	game.ReplicatedStorage.LeavingElevator2:FireServer()
	script.Parent.Visible = false
	wait(.5)
	workspace.ElevatorDoor2.Hitbox1.CanTouch = true
end)

And yes, i have multiple elevators

nvm ive already came up with a solution, you see the variable “isinElevator” is passed to the whole server, meaning that no one can touch the trigger unless the player inside leaves. All i had to to is to wait 1 second and set it to false when player touched trigger

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.