i dont know why i have so many problems everyday
So I made this code on if a player touches the primary/zone, the player teleports to a part and gets welded to the primary (the part that is moving the elevator). But it’s only once because of the debounce and if I removed the debounce, the elevator would move super fast. So I need help making a script that can support all players.
Basically when all players get into the elevator, the ending cutscene will start.
Server Script
local model = script.Parent
local primary = model.PrimaryPart
local tweenservice = game:GetService("TweenService")
local debounce = false
local gui = Instance.new("ScreenGui")
local frame = Instance.new("Frame")
function ending()
workspace["PM (PlaceholderMusic)"]["Elevator Jammed"]:Play()
task.wait(1)
local tween = tweenservice:Create(primary,TweenInfo.new(25.3, Enum.EasingStyle.Cubic, Enum.EasingDirection.In), {CFrame = primary.CFrame + Vector3.new(0,-175,0)})
tween:Play()
tween.Completed:Wait()
local ahhhhtween = tweenservice:Create(primary,TweenInfo.new(15, Enum.EasingStyle.Circular, Enum.EasingDirection.In), {CFrame = primary.CFrame + Vector3.new(0,-3000,0)})
ahhhhtween:Play()
end
game.Players.PlayerAdded:Connect(function(player)
primary.Touched:Connect(function(hit)
print(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
local weld = Instance.new("WeldConstraint")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://103845461454072"
local rahhhh = hit.Parent.Humanoid:LoadAnimation(anim)
rahhhh:Play()
hit.Parent.HumanoidRootPart.CFrame = model.tppart.CFrame
weld.Parent = model
weld.Part0 = hit.Parent.HumanoidRootPart
weld.Part1 = primary
task.wait(0.3)
ending()
task.wait(13.8)
player.PlayerGui.DeadGui.Enabled = true
end
end
end)
end)
2 Likes
here is a simple serverscript that tells you if everyone is touching a part
-- just so it loads this is just a basic example
wait(5)
local primary = workspace:WaitForChild("e")
local players = game.Players:GetPlayers()
for _, player in pairs(players) do
local count = 0
player.Character.HumanoidRootPart.Touched:Connect(function(e)
if e == primary then
count += 1
end
-- Check if all players are touching the primary object
if count == #players then
print("Everyone is touching the part")
end
end)
end
2 Likes
This tells you if everyone has touched the part at some point in time, not if everyone is currently touching the part
Did I something wrong because when I tried in multiplayer, Player1 entered the elevator and the cutscene instantly plays and the elevator was insanely fast.
local model = script.Parent
local primary = model.PrimaryPart
local tweenservice = game:GetService("TweenService")
local debounce = false
local player = game:GetService("Players").PlayerAdded:Wait()
function ending()
workspace["PM (PlaceholderMusic)"]["Elevator Jammed"]:Play()
task.wait(1)
local tween = tweenservice:Create(primary,TweenInfo.new(25.3, Enum.EasingStyle.Cubic, Enum.EasingDirection.In), {CFrame = primary.CFrame + Vector3.new(0,-175,0)})
tween:Play()
tween.Completed:Wait()
local ahhhhtween = tweenservice:Create(primary,TweenInfo.new(15, Enum.EasingStyle.Circular, Enum.EasingDirection.In), {CFrame = primary.CFrame + Vector3.new(0,-3000,0)})
ahhhhtween:Play()
end
primary.Touched:Connect(function(hit)
print(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local players = game.Players:GetPlayers()
for _, player in pairs(players) do
local count = 0
player.Character.HumanoidRootPart.Touched:Connect(function(e)
if e == primary then
count += 1
end
-- Check if all players are touching the primary object
if count == #players then
local weld = Instance.new("WeldConstraint")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://103845461454072"
local rahhhh = hit.Parent.Humanoid:LoadAnimation(anim)
rahhhh:Play()
hit.Parent.HumanoidRootPart.CFrame = model.tppart.CFrame
weld.Parent = model
weld.Part0 = hit.Parent.HumanoidRootPart
weld.Part1 = primary
task.wait(0.3)
ending()
task.wait(13.8)
player.PlayerGui.DeadGui.Enabled = true
end
end)
end
end
end)
1 Like
looks like theres no debounce on the touched bit try using the debouncr
1 Like
Ok ik whats wrong. get the player id and make sure that no 2 player ids that enter are the same
its detecting 2 of the same player.
player.PlayerId I think idk you can look it up
If you want to see what’s wrong, here is the video (the elevator detects the player a bunch of times so the tween gets added up a bunch which is more than the original goal)
output
21:46:33.560 RightHand - Server - Main:17
21:46:33.568 LowerTorso - Server - Main:17
21:46:33.575 Head - Server - Main:17
21:46:33.580 RightUpperLeg - Server - Main:17
21:46:33.586 RightFoot - Server - Main:17
21:46:33.589 RightLowerLeg - Server - Main:17
21:46:33.592 LeftHand - Server - Main:17
21:46:33.595 Handle - Server - Main:17
21:46:33.597 RightUpperArm - Server - Main:17
21:46:33.599 LeftLowerLeg - Server - Main:17
21:46:33.601 Handle - Server - Main:17
21:46:33.603 UpperTorso - Server - Main:17
21:46:33.605 HumanoidRootPart - Server - Main:17
21:46:33.607 LeftUpperLeg - Server - Main:17
21:46:33.609 LeftUpperArm - Server - Main:17
21:46:33.611 RightLowerArm - Server - Main:17
21:46:33.613 LeftLowerArm - Server - Main:17
21:46:33.615 LeftFoot - Server - Main:17
21:46:33.671 RightFoot - Server - Main:17
21:46:33.674 LeftHand - Server - Main:17
21:46:33.770 RightHand - Server - Main:17
21:46:33.775 LowerTorso - Server - Main:17
21:46:33.777 Head - Server - Main:17
21:46:33.780 RightUpperLeg - Server - Main:17
21:46:33.783 RightFoot - Server - Main:17
21:46:33.785 LeftHand - Server - Main:17
21:46:33.788 RightLowerLeg - Server - Main:17
21:46:33.790 HumanoidRootPart - Server - Main:17
21:46:33.795 RightUpperArm - Server - Main:17
21:46:33.798 LeftLowerLeg - Server - Main:17
21:46:33.801 UpperTorso - Server - Main:17
21:46:33.803 LeftUpperLeg - Server - Main:17
21:46:33.805 Handle - Server - Main:17
21:46:33.808 Handle - Server - Main:17
21:46:33.810 LeftUpperArm - Server - Main:17
21:46:33.812 RightLowerArm - Server - Main:17
21:46:33.815 LeftFoot - Server - Main:17
21:46:33.819 LeftLowerArm - Server - Main:17
21:47:46.307 Disconnect from ::ffff:127.0.0.1|57882 - Studio
Tween-stacking is not possible. The API states that applying another tween on the same property overrides the previous tween. Are you sure you’re not experiencing a visual illusion? Try observing the velocity of the platform or character to see if any acceleration is really happening
Well once I tried it with a debounce, it worked finely and the elevator didn’t go fast like this. But it was an old script.
I probably thought that it wouldn’t work with the debounce before I tested it. Like this was the change I made.
if count == #players then
if not debounce then
debounce = true
local weld = Instance.new("WeldConstraint")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://103845461454072"
local rahhhh = hit.Parent.Humanoid:LoadAnimation(anim)
rahhhh:Play()
hit.Parent.HumanoidRootPart.CFrame = model.tppart.CFrame
weld.Parent = model
weld.Part0 = hit.Parent.HumanoidRootPart
weld.Part1 = primary
task.wait(0.3)
ending()
task.wait(13.8)
player.PlayerGui.DeadGui.Enabled = true
end
end
So I might test it now
it didn’t work. It only led 1 player in
What I’m looking at here seems pretty characteristic of an exponential tween approaching a vertical decline of three thousand studs
Because it’s like an elevator falling 2 miles (probably) I could probably decrease the amount though
This doesn’t seem efficient anyways. I would use moving textures to create the idea of falling
So basically after the first tween, the walls would move up to recreate an elevator falling effect. Is that what you mean by that?
No. A texture on the wall would be manipulated to create the illusion of movement
So it’s just like in the Doors Floor 2 intro?
If you have the admin panel and have peaked outside of the elevator, and the elevator has virtually no height, then yes
How would I make the illusion though? Beams? Particles?
I presume it’s being done through textures
I know thats what im saying. just detect the playerid of each player that walks in and store it. then next check, if the playerid of the player that touched the thing matches a playerid in the list, it doesnt add to count.
oh true. just after each check wipe the table storing the playerids.