Hello. I’ve made a rope, where you can press E, and it teleports you to the other side, but for some reason, as you do it in the second time (>) it will break and teleport you somewhere.
Here is my code:
local remoteEvent = game.ReplicatedStorage.Rope;
local function server_Event(player, startedCFrame, endCFrame)
local animation = script.Animation;
local humanoid = player.Character.Humanoid;
local track = humanoid:LoadAnimation(animation)
track:Play()
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
humanoid.Parent.HumanoidRootPart.Anchored = true
humanoid.Parent.UpperTorso.CFrame = startedCFrame
local tweenService = game:GetService("TweenService");
local tweenInfo = TweenInfo.new(3);
local goal = {
Position = endCFrame
};
wait(0.25)
tweenService:Create(humanoid.Parent.HumanoidRootPart, tweenInfo, goal):Play()
wait(3)
humanoid.Parent.HumanoidRootPart.Anchored = false
track:Stop()
wait(1)
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
end;
remoteEvent.OnServerEvent:Connect(server_Event)
Here is a video of what is happening: https://streamable.com/sgosj3
Client script (I do not find it necessary but you may do):
local billbaord = script.Parent;
local userInputService = game:GetService("UserInputService");
local lastUI = nil;
local lastInteractable = nil;
local function input_Began(input, isTyping)
if isTyping then return end;
local cancalled = false;
if input.KeyCode ~= Enum.KeyCode.E then return end;
local tweenService = game:GetService("TweenService");
local tweenInfo = TweenInfo.new(0.2);
local goal = {
Size = UDim2.new(0.428, 0,0.866, 0);
BackgroundColor3 = Color3.fromRGB(41, 82, 124)
};
tweenService:Create(lastUI.Around.Inside, tweenInfo, {
BackgroundColor3 = Color3.fromRGB(41, 82, 124)
}):Play()
local track = tweenService:Create(lastUI.Around, tweenInfo, goal);
track:Play()
lastUI.Around.Inside.InsideBar.Size = UDim2.new(0.34, 0,0.363, 0)
lastUI.Around.Inside.InsideBar.Visible = true
local track2 = tweenService:Create(lastUI.Around.Inside.InsideBar, TweenInfo.new(0.2), {
Size = UDim2.new(1, 0, 1, 0)
})
track2:Play()
userInputService.InputEnded:Connect(function(input, isTyping)
if isTyping then return end;
if input.KeyCode == Enum.KeyCode.E then
cancalled = true
tweenService:Create(lastUI.Around, tweenInfo, {
Size = UDim2.new(0.528, 0,1.006, 0);
BackgroundColor3 = Color3.fromRGB(85, 170, 255)
}):Play()
tweenService:Create(lastUI.Around.Inside, tweenInfo, {
BackgroundColor3 = Color3.fromRGB(85, 170, 255)
}):Play()
lastUI.Around.Inside.InsideBar.Visible = false
else
end
end)
local currentTIme = os.time();
repeat wait()
until cancalled == true or os.time() - currentTIme > 0.2
if cancalled then
print("Duration of holding E is shorter than the required, not firing remote events [Duration]")
else
if lastInteractable.Name == "LGBTQ" then
game.ReplicatedStorage.AddToInventory:FireServer(lastInteractable:FindFirstChildOfClass("StringValue"))
elseif lastInteractable.Name == "Rope" then
game.ReplicatedStorage.Rope:FireServer(workspace.FirstRopeCFrameVector.CFrame, workspace.LastPartForCFrame.Position)
end
tweenService:Create(lastUI.Around, tweenInfo, {
Size = UDim2.new(0.528, 0,1.006, 0);
BackgroundColor3 = Color3.fromRGB(85, 170, 255)
}):Play()
tweenService:Create(lastUI.Around.Inside, tweenInfo, {
BackgroundColor3 = Color3.fromRGB(85, 170, 255)
}):Play()
lastUI.Around.Inside.InsideBar.Visible = false
end
end;
userInputService.InputBegan:Connect(input_Began)
while wait() do
local closestPoint = 7;
local interactables = workspace.Interactables:GetChildren();
if lastInteractable and (game.Players.LocalPlayer.Character.UpperTorso.Position - lastInteractable.Position).Magnitude > closestPoint then lastUI:Destroy() else end
for _, v in ipairs(interactables) do
if (game.Players.LocalPlayer.Character.UpperTorso.Position - v.Position).Magnitude < closestPoint then
lastInteractable = v
local clone = script.Interaction:Clone();
clone.Parent = v;
lastUI = clone
repeat wait()
until (game.Players.LocalPlayer.Character.UpperTorso.Position - v.Position).Magnitude > closestPoint
lastUI:Destroy()
else
end
end
end
The line where I fire the Remote Event in the Client script:
game.ReplicatedStorage.Rope:FireServer(workspace.FirstRopeCFrameVector.CFrame, workspace.LastPartForCFrame.Position)